From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Pallavi Kadam <pallavi.kadam@intel.com>,
Dmitry Malloy <dmitrym@microsoft.com>,
Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
Tyler Retzlaff <roretzla@linux.microsoft.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Olivier Matz <olivier.matz@6wind.com>
Subject: [dpdk-dev] [PATCH 4/4] net: replace Windows networking shim
Date: Sat, 13 Mar 2021 04:56:16 +0300 [thread overview]
Message-ID: <20210313015616.29790-5-dmitry.kozliuk@gmail.com> (raw)
In-Reply-To: <20210313015616.29790-1-dmitry.kozliuk@gmail.com>
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 <rte_ether.h> 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 <dmitry.kozliuk@gmail.com>
---
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/sys/socket.h | 24 -------------
lib/librte_net/rte_ether.h | 26 ++++++++++----
lib/librte_net/rte_ip.h | 15 ++++++++
6 files changed, 35 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/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 <winsock2.h> would expose too much macros breaking common code.
- */
-
-#include <netinet/in.h>
-#include <sys/socket.h>
-
-/* 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 <stdint.h>
-#include <sys/socket.h>
-
-#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/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 <winsock2.h> would expose too much macros breaking common code.
- */
-
-#include <stddef.h>
-
-#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 <rte_mbuf.h>
#include <rte_byteorder.h>
-#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 f8a08deed5..6c9904698a 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -17,10 +17,25 @@
#include <stdint.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
+
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
+#else
+
+#include <ws2tcpip.h>
+
+#ifdef RTE_BUILD_INTERNAL
+#define IPVERSION 4 /* missing from Windows SDK */
+#define IPPROTO_IPIP 4 /* missing from Windows SDK and MinGW */
+#define IPPROTO_GRE 47 /* ditto */
+#define IPPROTO_SCTP 132 /* missing from MinGW */
+#endif
+
+#endif /* RTE_EXEC_ENV_WINDOWS */
+
#include <rte_byteorder.h>
#include <rte_mbuf.h>
--
2.29.2
next prev parent reply other threads:[~2021-03-13 1:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-13 1:56 [dpdk-dev] [PATCH 0/4] " Dmitry Kozlyuk
2021-03-13 1:56 ` [dpdk-dev] [PATCH 1/4] cmdline: remove POSIX dependency Dmitry Kozlyuk
2021-03-13 1:56 ` [dpdk-dev] [PATCH 2/4] ethdev: " Dmitry Kozlyuk
2021-03-13 1:56 ` [dpdk-dev] [PATCH 3/4] net/mlx5: " Dmitry Kozlyuk
2021-03-13 1:56 ` Dmitry Kozlyuk [this message]
2021-03-13 2:56 ` [dpdk-dev] [PATCH v2 0/4] net: replace Windows networking shim Dmitry Kozlyuk
2021-03-13 2:56 ` [dpdk-dev] [PATCH v2 1/4] cmdline: remove POSIX dependency Dmitry Kozlyuk
2021-03-13 2:56 ` [dpdk-dev] [PATCH v2 2/4] ethdev: " Dmitry Kozlyuk
2021-03-13 2:56 ` [dpdk-dev] [PATCH v2 3/4] net/mlx5: " Dmitry Kozlyuk
2021-03-13 2:56 ` [dpdk-dev] [PATCH v2 4/4] net: replace Windows networking shim Dmitry Kozlyuk
2021-03-13 22:22 ` [dpdk-dev] [PATCH v3 0/4] " Dmitry Kozlyuk
2021-03-13 22:22 ` [dpdk-dev] [PATCH v3 1/4] cmdline: remove POSIX dependency Dmitry Kozlyuk
2021-03-17 17:22 ` Tyler Retzlaff
2021-03-13 22:22 ` [dpdk-dev] [PATCH v3 2/4] ethdev: " Dmitry Kozlyuk
2021-03-17 17:22 ` Tyler Retzlaff
2021-03-13 22:22 ` [dpdk-dev] [PATCH v3 3/4] net/mlx5: " Dmitry Kozlyuk
2021-03-17 17:22 ` Tyler Retzlaff
2021-03-13 22:22 ` [dpdk-dev] [PATCH v3 4/4] net: replace Windows networking shim Dmitry Kozlyuk
2021-03-15 13:03 ` [dpdk-dev] [PATCH v3 0/4] " Ferruh Yigit
2021-03-15 13:23 ` Dmitry Kozlyuk
2021-03-17 19:19 ` Ranjit Menon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210313015616.29790-5-dmitry.kozliuk@gmail.com \
--to=dmitry.kozliuk@gmail.com \
--cc=dev@dpdk.org \
--cc=dmitrym@microsoft.com \
--cc=navasile@linux.microsoft.com \
--cc=olivier.matz@6wind.com \
--cc=pallavi.kadam@intel.com \
--cc=roretzla@linux.microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).