From patchwork Sat Mar 20 13:05:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 89594 X-Patchwork-Delegate: david.marchand@redhat.com 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 DFB91A0524; Sat, 20 Mar 2021 14:06:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A4A4E1410A7; Sat, 20 Mar 2021 14:05:53 +0100 (CET) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by mails.dpdk.org (Postfix) with ESMTP id 795074067A for ; Sat, 20 Mar 2021 14:05:50 +0100 (CET) Received: by mail-lf1-f54.google.com with SMTP id 75so14239755lfa.2 for ; Sat, 20 Mar 2021 06:05:50 -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=sMD8/jEHhJjSShrF3NYEM+OecTUns5X1WpDa+HI4auI=; b=oMv08dVJrSATTVml9H8xv5J5ExGRP2+rp2ZmxG7Wir2NLeRQ+ccFeno964j5aLsNew sH3pLK6mq0Amj399Tg+SQjxo2rcz4+AAkDgTItuhUFZrhMCd4pky5zsLWR4UgJZU+3Jf HhAWQQ+9/bQkDh31GFzj0xJSZrCALKACzw4ETUhwujtgNVyQRMYIkGGVhzA5j2b2aJ+9 RJjpoQD/qZ1CuklkNyudhaNvdsZ1/fGkaP9foCwvVSGIYrCuKKi/MzP7qyMMrwifH6Xu CPVuHhZCzSb4/DzmbN9GFBrF9ZjPcO44IMYiFTzvfqYvZ2ltHVJiZyCVb1I2M9UlyG91 Q/Yg== 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=sMD8/jEHhJjSShrF3NYEM+OecTUns5X1WpDa+HI4auI=; b=F3tDJR83Bvt+qkmZyGeeaLWNUh8Y+PAZHGHOUhMDKOIhqnlwCO3RNn2r/+VdnZl9YR /nC9rB1xnqVvIsOe7qREHqZuwvGNeuKpdOVVH+SlR2yuP3k6lal6kF7wYAQ9kQWaPoeA PIiqGoGJGLbX8sDEcR7+LrsV39LYTNnZhuDUSN/DMBEj5vUb6nCllP4U52HwLKsDhW1F WRsdeKnpElsvzYpBvY2kHnYvFGomjia3XxeU8CUSiaCO8LVpZp86QfEeGYWUoKuZAoNC ZONPtaiwJlj/d6+JugOfVhxDnJshr1cDB1Ggja1dUwvhx8jM16JTVLS7xvYViJ9ZPpqQ iMcA== X-Gm-Message-State: AOAM530wbLcqYp4akytIc1xNRqTi9SeLg/4JYfT2FRJqyA60tRpVnEL0 V8JPYpefg6/pfc60nTwDvc+/2Kl28lasWphk X-Google-Smtp-Source: ABdhPJwvE6oV8VzbSBVDSKEwCSDy5Ddzyn6FQJvZyl3LbAaWe7PBKD2bUJoqN15qzDx8PBsNlWrxgA== X-Received: by 2002:a19:f50d:: with SMTP id j13mr3756355lfb.545.1616245548351; Sat, 20 Mar 2021 06:05:48 -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 r66sm929610lff.93.2021.03.20.06.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:05:47 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Dmitry Kozlyuk , Khoa To , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Ray Kinsella , Neil Horman Date: Sat, 20 Mar 2021 16:05:21 +0300 Message-Id: <20210320130525.16452-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210320130525.16452-1-dmitry.kozliuk@gmail.com> References: <20210320112733.13160-1-dmitry.kozliuk@gmail.com> <20210320130525.16452-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 1/5] eal: add sleep API 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" POSIX sleep(3) is missing from Windows. Add generic rte_thread_sleep() to suspend current OS thread. Signed-off-by: Dmitry Kozlyuk Acked-by: Khoa To --- lib/librte_eal/common/eal_common_timer.c | 5 +++-- lib/librte_eal/include/rte_thread.h | 11 +++++++++++ lib/librte_eal/rte_eal_exports.def | 2 ++ lib/librte_eal/unix/rte_thread.c | 10 +++++++++- lib/librte_eal/version.map | 1 + lib/librte_eal/windows/eal_thread.c | 9 ++++++++- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c index 71e0bd035a..0e89a4f7df 100644 --- a/lib/librte_eal/common/eal_common_timer.c +++ b/lib/librte_eal/common/eal_common_timer.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "eal_private.h" #include "eal_memcfg.h" @@ -47,9 +48,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_thread_sleep(1) will sleep for 1 second */ uint64_t start = rte_rdtsc(); - sleep(1); + rte_thread_sleep(1); /* Round up to 10Mhz. 1E7 ~ 10Mhz */ return RTE_ALIGN_MUL_NEAR(rte_rdtsc() - start, CYC_PER_10MHZ); } diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e640ea1857..f0c12dd79d 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -106,6 +106,17 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); __rte_experimental void *rte_thread_tls_value_get(rte_tls_key key); +/** + * Suspend current OS thread for the specified time, yielding CPU to scheduler. + * + * @param sec + * Number of seconds to sleep. The system may return control later, + * but not earlier. Zero value always yields the CPU, but control may be + * returned immediately. + */ +__rte_experimental +void rte_thread_sleep(unsigned int sec); + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def index 474cf123fa..494240b940 100644 --- a/lib/librte_eal/rte_eal_exports.def +++ b/lib/librte_eal/rte_eal_exports.def @@ -334,3 +334,5 @@ EXPORTS rte_mem_map rte_mem_page_size rte_mem_unmap + + rte_thread_sleep diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86ffeebc95..91babfe887 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -3,10 +3,12 @@ */ #include -#include #include #include +#include +#include + #include #include #include @@ -84,3 +86,9 @@ rte_thread_tls_value_get(rte_tls_key key) } return pthread_getspecific(key->thread_index); } + +void +rte_thread_sleep(unsigned int sec) +{ + sleep(sec); +} diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index 48a2b55d57..da527f41bf 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -415,6 +415,7 @@ EXPERIMENTAL { rte_thread_tls_value_set; # added in 21.05 + rte_thread_sleep; rte_version_minor; rte_version_month; rte_version_prefix; diff --git a/lib/librte_eal/windows/eal_thread.c b/lib/librte_eal/windows/eal_thread.c index 9c3f6d69fd..c84e67009c 100644 --- a/lib/librte_eal/windows/eal_thread.c +++ b/lib/librte_eal/windows/eal_thread.c @@ -11,9 +11,10 @@ #include #include #include -#include +#include #include "eal_private.h" +#include "eal_thread.h" #include "eal_windows.h" /* @@ -154,3 +155,9 @@ rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name) /* This is a stub, not the expected result */ return 0; } + +void +rte_thread_sleep(unsigned int sec) +{ + return Sleep(MS_PER_S * sec); +} From patchwork Sat Mar 20 13:05:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 89593 X-Patchwork-Delegate: david.marchand@redhat.com 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 B739AA0524; Sat, 20 Mar 2021 14:05:58 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58149141097; Sat, 20 Mar 2021 14:05:52 +0100 (CET) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by mails.dpdk.org (Postfix) with ESMTP id 26E654067A for ; Sat, 20 Mar 2021 14:05:50 +0100 (CET) Received: by mail-lj1-f174.google.com with SMTP id z25so15290801lja.3 for ; Sat, 20 Mar 2021 06:05:50 -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=MArFPjIlL4GVujy8IhDC+Gb3oAVqevXZD0N3E/6IAg4=; b=cKjTNqSJ7pcIp2M7VngjLiyjsx++84gmTOLbQJ/nzkWJDGhhdiCeIWGSPYXCDUtkwJ Flw2NScG1AZjeM+vaTjur1ztOKntg9zHMM3sFbo1/0fr/AnbavX/WRedvKlnWntqWMvp JS17/P6OZsG65Gmq0KUiZAeukxmA3b4+E+skhUuxNwf5FVyG4I1ERSrD51DxX+6tNhew 81/Btv5j3VjDEDIASbzErAM9oNRRHyFXdTwkloPOWWonHAWRMppSRxuG5koj5hGsPWuP 7iCLCo67/mOld3Q7JwgPUImtdIIadCGJEEGffvflV+PWWlh1SFfSWE2b5X3pTvqCRUHl e3CQ== 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=MArFPjIlL4GVujy8IhDC+Gb3oAVqevXZD0N3E/6IAg4=; b=g3lYSVQWA+q/aJQ8G/If+LJmZZhjKVbE7svKeo69zaufdJsn8IYbnxFpMVV4F97pPB 7XmXk5FQxg3WnwECB5+V32dmpwJxuqeKUvyecNq9O/M7D0VupkzAfAnAY+9/MGVbDwPE N7JbJNlz/FvpOhdcFG+utqVybT+pr2qJxGAqTIPx4oGh4EtDEfeLYE0jY3CDQ/gO6dpk 6wJnY+cKgXuW78lYgBWaGoDACtwNl9+L8oKQVqBEuau2PIszblHDI0WiWA+N+9xldwpM rhKKE01f5b4eefrevGc9Bc1J77GJ4VF8ezyT8PfhpyXYamf7ZS2OvnQ8sLD+fcdbC8MA es2A== X-Gm-Message-State: AOAM5314v9/4h0kMY/Nj+TrZ1rUm30x767udqcUIDvQSRWnp3WB9FYIT gIbrL9CGjOWLVug5VTYNC6Y5J1WEIBSaQACY X-Google-Smtp-Source: ABdhPJxLIOxqgf9ZLquxbk2TrDpigoczPfUXPzKM5S1xoS4U9MBIhvpiarP0wsJ0ii0cXLaG3eKgww== X-Received: by 2002:a2e:720c:: with SMTP id n12mr3871285ljc.67.1616245549445; Sat, 20 Mar 2021 06:05:49 -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 r66sm929610lff.93.2021.03.20.06.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:05:48 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Dmitry Kozlyuk , Khoa To , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Sat, 20 Mar 2021 16:05:22 +0300 Message-Id: <20210320130525.16452-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210320130525.16452-1-dmitry.kozliuk@gmail.com> References: <20210320112733.13160-1-dmitry.kozliuk@gmail.com> <20210320130525.16452-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 2/5] 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 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index b8a0d20021..31eda4d2da 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -745,4 +745,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 2fc3d6141c..162671f9ce 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 @@ -411,6 +413,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, From patchwork Sat Mar 20 13:05:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 89595 X-Patchwork-Delegate: david.marchand@redhat.com 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 40DC4A0524; Sat, 20 Mar 2021 14:06:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65C741410B2; Sat, 20 Mar 2021 14:05:58 +0100 (CET) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mails.dpdk.org (Postfix) with ESMTP id 2658B14109F for ; Sat, 20 Mar 2021 14:05:53 +0100 (CET) Received: by mail-lf1-f52.google.com with SMTP id u10so14236289lff.1 for ; Sat, 20 Mar 2021 06:05:53 -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=jV4Q84rpa1TkoRk0eFR3wJmzCTuxSpdPkYzC+NaCbYg=; b=qvsoVqywKhC1kRHmtH6ayUokOHBDAPYms7f+z7fwSDtHkDzpdzKGxLb/rv/Q6qCxTB IvLecRUMpduJtuJfbRQKzrWH5B+/PHK9RyHlW2Gl9L4hlgTSK5XLfnzH2/HiVsyPEWfP HNsjWBedTIayIzq00bG9hRAA27fz6oh2UQTax5KqFqp6HFRhjPgdf+72+1ioV/RBJbsM 3fjIS0trcNvYKMO8IQZBKXcAEPWPyMca7ctZJnwN88h7nYKAGv+wkjd/oyV9Otvb69T5 M18BIiNM67l17tyUuVfxIfdT5qFGeD1nGFVTw8Vt3S6SXYioLEOgkPum514x3v9+snoq fvgA== 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=jV4Q84rpa1TkoRk0eFR3wJmzCTuxSpdPkYzC+NaCbYg=; b=qOimjEG8IJ5PVp4Vb7X1LtLzV4mrFPCGXYaMNbNNsRPP9sXBIW/URwe6laiBOWw04h solvh9jryhe5YFHVcNOSoHpka4rDdkK5fOucjKtWYrgLtJcLPI11t4rz1SnPmtk/lp2K QzLLzjPIm5cuwkMbKnqoxEBFdTji0IvpSJsNFYLkCbeD+gR00A38wAqH6SaAhR6NLWPU Ykkjie9R8bK4TpKNxzijCp1Pu6pZmHT+Ukj/VXtVYkIp4I1Bu4vHyjPSh9sUfhOJn9Ys r4P1jnwiUVwJirgQP0/8QUP8LBkkRh3Qk6qW5VPvAxpK8geMvVipQ6ZaDsl0ldDsq3eD 3WZQ== X-Gm-Message-State: AOAM533sLmQ9ERyGX5msDVTS20HTJRljUc/GL8v/JM5xXo0+LxfviUqa UYLUQQMAXj+MQcB6GzG2Us6Z+ia/1Zq3GXUZ X-Google-Smtp-Source: ABdhPJyIM0W9uU0wOzFN1GdXwYdUqOMEWjtIz3FT1Vq5BpoySCk022ZZUK1emRFTqYAZ4Jb2lAYHhA== X-Received: by 2002:a05:6512:3709:: with SMTP id z9mr3527189lfr.557.1616245550697; Sat, 20 Mar 2021 06:05:50 -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 r66sm929610lff.93.2021.03.20.06.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:05:50 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Dmitry Kozlyuk , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Beilei Xing , Jeff Guo , Olivier Matz , Bruce Richardson , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Sat, 20 Mar 2021 16:05:23 +0300 Message-Id: <20210320130525.16452-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210320130525.16452-1-dmitry.kozliuk@gmail.com> References: <20210320112733.13160-1-dmitry.kozliuk@gmail.com> <20210320130525.16452-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 3/5] 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 all shims to , a header to be used instead of by internal code. Include it in libraries and PMDs that previously imported shims from . Signed-off-by: Dmitry Kozlyuk --- 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 + 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_options.c | 2 +- lib/librte_eal/common/eal_internal_cfg.h | 1 + .../freebsd/include/rte_os_internal.h | 14 +++ .../linux/include/rte_os_internal.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 | 92 +------------------ .../windows/include/rte_os_internal.h | 28 ++++++ lib/librte_ethdev/ethdev_private.h | 2 + lib/librte_kvargs/rte_kvargs.c | 1 + 21 files changed, 77 insertions(+), 104 deletions(-) create mode 100644 lib/librte_eal/freebsd/include/rte_os_internal.h create mode 100644 lib/librte_eal/linux/include/rte_os_internal.h create mode 100644 lib/librte_eal/windows/include/rte_os_internal.h diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index f566943f5e..d95e6f71a2 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..1a60c1b5d2 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 3855582d0d..14b061690f 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 d7cd049891..0719504e24 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/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..ca45db9493 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_options.c b/lib/librte_eal/common/eal_common_options.c index 622c7bc429..28da464fc9 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1936,7 +1936,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_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h index 51dbe86e2b..fc7cb3efaf 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_internal.h b/lib/librte_eal/freebsd/include/rte_os_internal.h new file mode 100644 index 0000000000..cabe9648fa --- /dev/null +++ b/lib/librte_eal/freebsd/include/rte_os_internal.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_INTERNAL_H_ +#define _RTE_OS_INTERNAL_H_ + +#include + +/** + * @file + * @internal + * Provides semi-standard OS facilities by convenient names. + */ + +#endif /* _RTE_OS_INTERNAL_H_ */ diff --git a/lib/librte_eal/linux/include/rte_os_internal.h b/lib/librte_eal/linux/include/rte_os_internal.h new file mode 100644 index 0000000000..cabe9648fa --- /dev/null +++ b/lib/librte_eal/linux/include/rte_os_internal.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_INTERNAL_H_ +#define _RTE_OS_INTERNAL_H_ + +#include + +/** + * @file + * @internal + * Provides semi-standard OS facilities by convenient names. + */ + +#endif /* _RTE_OS_INTERNAL_H_ */ 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 7ef38ff06c..8d845c57b7 100644 --- a/lib/librte_eal/windows/include/rte_os.h +++ b/lib/librte_eal/windows/include/rte_os.h @@ -11,7 +11,6 @@ * Windows OS. It must not include Windows-specific headers. */ -#include #include #include #include @@ -20,101 +19,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 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) -{ - 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_internal.h b/lib/librte_eal/windows/include/rte_os_internal.h new file mode 100644 index 0000000000..84e39eb2ae --- /dev/null +++ b/lib/librte_eal/windows/include/rte_os_internal.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_INTERNAL_H_ +#define _RTE_OS_INTERNAL_H_ + +#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_INTERNAL_H_ */ diff --git a/lib/librte_ethdev/ethdev_private.h b/lib/librte_ethdev/ethdev_private.h index 905a45c337..bd601072fa 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 285081c86c..f5221a2f71 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -6,6 +6,7 @@ #include #include +#include #include #include "rte_kvargs.h" From patchwork Sat Mar 20 13:05:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 89597 X-Patchwork-Delegate: david.marchand@redhat.com 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 BE77BA0548; Sat, 20 Mar 2021 14:06:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2B241410B7; Sat, 20 Mar 2021 14:06:00 +0100 (CET) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by mails.dpdk.org (Postfix) with ESMTP id A2C741410A6 for ; Sat, 20 Mar 2021 14:05:53 +0100 (CET) Received: by mail-lf1-f51.google.com with SMTP id b14so1005882lfv.8 for ; Sat, 20 Mar 2021 06:05:53 -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=AYyjo2/S2au+USIRMTq7NZb2qb5+Lxocq1L5hwbrinI=; b=gbsGJGCAhWLyOqSVDi0urVC+Gg0F2/fUmlR5wBEbyTlnO4tHrVR9S6xXdA6Q0pu0v8 tXRcQLOuM36HOxRJa/nRSQkGCtzJwcytmL4aCNbhcN7/RkSW/Mj/Zlmj6HDjrtCeVdTw P6VDSM2zrcIRycm+x58pDavMI3bPOjVFt8aW2A7/k93SQRYA1LtakdtSZkmqW8YgCOt/ KLHrFcbFu6YnPQrpVRR6s6UCI/jExSU/NHaGCwGWk7VI/P/Q/lTVwweFv0+HLDmYRji3 qwCNB5uk8UKNzntuNR4eW/pHFGVFaN7HPof62MW+j7BlSx3JSRUAS0QCq4jk8dCg+Lt6 780w== 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=AYyjo2/S2au+USIRMTq7NZb2qb5+Lxocq1L5hwbrinI=; b=MulqEJ8W7e6CsfeSQEojlf0531D5TDssmDfBczug1gdpUk6H0tcPcdroIMKt/rxfSA iKc8bW9hwwjgBmWoIVdHLof/A1J30hDzQKANABweCWjDEoJbr6UoqwPBoQ8Ct5SGnMIL +nzlzzgBTPpZ+1riWt71cigdcFo1JLe3AFFg3fve5jmH4tEdUpgF3NK+1ffeS9n6UlNu 44qA+DFItYUehhvXY7jdcQmB7etQnm3wzS9CAGCfdrpwDZIbcaDn9hCfCau4YC2gmMU9 +znWGV4HL/fos4hUvdDeojhEvwrVfbWrOkB+qRav6xZZtMz1yl78WWsPzwmfJsbAxa3V Y1Ug== X-Gm-Message-State: AOAM533wRjFonxyA2cItfg7L94ubd6yS+yltVCiyCgnzcPVbP9Hk3wow xnO4xG5HxwS0te/rVcl6gOshhwNdSrCacJAu X-Google-Smtp-Source: ABdhPJxYJfa5QahfAMFYvfWtpqIwOP9W6S5AzZajCbUFwa+TkRLjTGCs5zkMWcTTFk7iMpIE6zk4MA== X-Received: by 2002:a19:e34c:: with SMTP id c12mr3776084lfk.555.1616245551763; Sat, 20 Mar 2021 06:05:51 -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 r66sm929610lff.93.2021.03.20.06.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:05:51 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Dmitry Kozlyuk , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Olivier Matz , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Sat, 20 Mar 2021 16:05:24 +0300 Message-Id: <20210320130525.16452-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210320130525.16452-1-dmitry.kozliuk@gmail.com> References: <20210320112733.13160-1-dmitry.kozliuk@gmail.com> <20210320130525.16452-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 4/5] 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_* constatns, 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 include in components enabled on Windows. Signed-off-by: Dmitry Kozlyuk --- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 4 ++-- drivers/net/mlx5/mlx5_mac.c | 1 - examples/cmdline/commands.c | 5 ----- examples/cmdline/parse_obj_list.c | 2 -- 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_ethdev/rte_ethdev.c | 13 +++++-------- lib/librte_ethdev/rte_ethdev_core.h | 1 - lib/librte_net/rte_ip.h | 3 +++ 14 files changed, 14 insertions(+), 38 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index a281fd20ea..f04da06abd 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -10,7 +10,7 @@ #include #include #include -#include + #include #include diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ab5be3dacc..73253bd39e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3,13 +3,13 @@ * Copyright 2016 Mellanox Technologies, Ltd */ -#include -#include #include #include #include #include +#include + #include #include #include diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 8324e188e1..c4e5f19faa 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -5,12 +5,12 @@ #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 6ffcfcd97a..f0450735e2 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/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_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 6f514c388b..f363794369 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2,18 +2,15 @@ * 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 212ff2c4fd..2cf7b0bd28 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -16,7 +16,10 @@ */ #include + +#include #include +#include #include #include From patchwork Sat Mar 20 13:05:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 89596 X-Patchwork-Delegate: david.marchand@redhat.com 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 CB061A0524; Sat, 20 Mar 2021 14:06:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9524A1410B9; Sat, 20 Mar 2021 14:05:59 +0100 (CET) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by mails.dpdk.org (Postfix) with ESMTP id 86EB11410A4 for ; Sat, 20 Mar 2021 14:05:53 +0100 (CET) Received: by mail-lj1-f169.google.com with SMTP id 16so15254429ljc.11 for ; Sat, 20 Mar 2021 06:05:53 -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=wRv+OJzQ97c5WakjArkiA3XrHOzKsTTKD+Q5GPG1lmw=; b=HHnMC1PnE2RdwEooqtz/nmzhFI8XcqPynGZ0d4i609SOwcqwcIlmp+Z4mDu/X6pz92 IOYfWQBbt/68ATMjhsEHejl3VA/ekvk9ZWg7fFUIruu4sjlB99V/d/ochNFYlmfj82sd rDWE9ocGTt5rpWvM/wQAPjYDapM8AJDr3D6XBlse8pArTVj9ASsXzSEcN78piVf4sjek FzuTMfQFIYB9zjWQWB3T+L02QZ7zyB/SdwkTNskSg30yvIXQVKh9LphcBS9x/KffKg9I qi257I00TH9B1QQeHOASfagu/7QwCiuRONUNJvoNeXJLSjRoqidF/57gI99EEx3pqQLm L7qw== 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=wRv+OJzQ97c5WakjArkiA3XrHOzKsTTKD+Q5GPG1lmw=; b=RLMvOs5F4CRXTVQqYLGKkRAwCRrNY8ocB/mQ90UQiKhX+P2xEVlq+h/dAvGKBcM+7q hBnIg0K7U+4yy5R8i4Ry8EBl5s++qN1Nv4npe1tNGtlOdg5xRHXrvE6yzJKfvSPAJERY VJ2NcGiSWMRDDLpbFu8tMLcSW1w4xEHIFs2SIb7bO0mxcoyk+kSwqo4EHnsWmkMoTtSl 65oNkr2jpjuWh58uW/M6nOMEll9DZHpp6oi60lPGjY50yCAupQTAzyrnGs46V2yawjRF xZLdGvbsxsY4QuI9IlKzBhiY34BkXbTb6bIVV4cEK8MXKrgGgFO9W+Fiw+/XaWqLgOgq xRGw== X-Gm-Message-State: AOAM530RCUmB8LWh3qfsi/2018LzklVPvpptfeJ8g5hkw9UdlZxWpc/0 H9R9ZVVguR43LtNa05pvjYBW9a4ZaUA28KEY X-Google-Smtp-Source: ABdhPJz4Rieylp45CXgVOL4WP1msO4rXstiv5bDwc4ZWVNCPvwlwI/YJ/s4Oxd5a8ddevCpg4YVySg== X-Received: by 2002:a2e:8018:: with SMTP id j24mr3802205ljg.188.1616245552816; Sat, 20 Mar 2021 06:05:52 -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 r66sm929610lff.93.2021.03.20.06.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:05:52 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Dmitry Kozlyuk , Ranjit Menon , Beilei Xing , Jeff Guo , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Olivier Matz Date: Sat, 20 Mar 2021 16:05:25 +0300 Message-Id: <20210320130525.16452-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210320130525.16452-1-dmitry.kozliuk@gmail.com> References: <20210320112733.13160-1-dmitry.kozliuk@gmail.com> <20210320130525.16452-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 5/5] net: replace Windows networking 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" Remove networking shim from Windows EAL. Replace it with system headers with two workarounds: 1. Windows Sockets headers contain `#define s_addr S_un.S_addr`, which conflicts with `s_addr` field of `struct rte_ether_hdr`. Undefining this macro in had been breaking some usages of DPDK and Windows headers in one file. Renaming 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. 2. Provide some IPPROTO_* constants and IPVERSION, missing on Windows. Signed-off-by: Dmitry Kozlyuk Acked-by: Ranjit Menon --- drivers/net/i40e/i40e_fdir.c | 1 + 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 ----- .../windows/include/rte_os_internal.h | 8 ++++ lib/librte_eal/windows/include/sys/socket.h | 24 ------------ lib/librte_net/rte_ether.h | 26 ++++++++++--- lib/librte_net/rte_ip.h | 4 ++ lib/librte_net/rte_net.c | 1 + 9 files changed, 34 insertions(+), 108 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 c572d003cb..b8960ff5a3 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/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_internal.h b/lib/librte_eal/windows/include/rte_os_internal.h index 84e39eb2ae..89ac5c9cbd 100644 --- a/lib/librte_eal/windows/include/rte_os_internal.h +++ b/lib/librte_eal/windows/include/rte_os_internal.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_INTERNAL_H_ */ 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_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 diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index 2cf7b0bd28..3c24bc4ca4 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -17,11 +17,15 @@ #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..b615f8f839 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