Skip to contentSkip to conversation

net: replace Windows networking shim

PATCH Superseded Dmitry Kozlyuk 4 participants 21 messages Mar 13, 2021 – Mar 17, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net: replace Windows networking shim

Networking header shim in Windows EAL conflicts with system headers and tries to provide POSIX compatibility out of scope for DPDK. Remove dependency on POSIX headers from libraries supported on Windows, then replace shim with librte_net with workarounds.

A proposed deprecation notice is assumed:
http://patchwork.dpdk.org/project/dpdk/list/?series=15595

Depends-on: series-15513 ("eal/windows: do not expose POSIX symbols")

Dmitry Kozlyuk (4):
cmdline: remove POSIX dependency
ethdev: remove POSIX dependency
net/mlx5: remove POSIX dependency
net: replace Windows networking shim

 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                  |  1 -
 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_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_ethdev/rte_ethdev.c               | 13 +++----
 lib/librte_ethdev/rte_ethdev_core.h          |  1 -
 lib/librte_net/rte_ether.h                   | 26 ++++++++++----
 lib/librte_net/rte_ip.h                      | 18 +++++++++-
 19 files changed, 48 insertions(+), 143 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
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/4 cmdline: remove POSIX dependency

Use <rte_ip.h> for IP-related defines instead of POSIX headers.

---
 examples/cmdline/commands.c                  | 1 -
 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_net/rte_ip.h                      | 3 ++-
 8 files changed, 3 insertions(+), 20 deletions(-)
examples/cmdline/commands.c +0 -1
index f43eacfbad..2c62d04fb0 100644
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <errno.h>
-#include <netinet/in.h>
 #ifdef RTE_EXEC_ENV_FREEBSD
 #include <sys/socket.h>
 #endif
examples/cmdline/parse_obj_list.c +0 -2
index b04adbea58..959bcd1452 100644
@@ -6,11 +6,9 @@
 
 #include <stdio.h>
 #include <inttypes.h>
-#include <stdarg.h>
 #include <errno.h>
 #include <ctype.h>
 #include <string.h>
-#include <netinet/in.h>
 
 #include <cmdline_parse.h>
 #include <cmdline_parse_ipaddr.h>
lib/librte_cmdline/cmdline.c +0 -1
index 49770869bb..a176d15130 100644
@@ -12,7 +12,6 @@
 #include <inttypes.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <netinet/in.h>
 
 #include <rte_string_fns.h>
 
lib/librte_cmdline/cmdline_parse.c +0 -2
index fe366841cd..f5cc934782 100644
@@ -11,8 +11,6 @@
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <netinet/in.h>
-
 #include <rte_string_fns.h>
 
 #include "cmdline_private.h"
lib/librte_cmdline/cmdline_parse_etheraddr.c +0 -6
index 5cb10de321..433b828a72 100644
@@ -5,13 +5,7 @@
  */
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <ctype.h>
 #include <string.h>
-#include <sys/types.h>
 
 #include <rte_string_fns.h>
 #include <rte_ether.h>
lib/librte_cmdline/cmdline_parse_ipaddr.c +0 -6
index f8dbdf204c..5e278c963f 100644
@@ -6,14 +6,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <ctype.h>
 #include <string.h>
 #include <errno.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
 
 #include <rte_string_fns.h>
 
lib/librte_cmdline/cmdline_parse_ipaddr.h +1 -1
index 0ba81647bc..0118c31d44 100644
@@ -8,7 +8,7 @@
 #define _PARSE_IPADDR_H_
 
 #include <cmdline_parse.h>
-#include <netinet/in.h>
+#include <rte_ip.h>
 
 #ifdef __cplusplus
 extern "C" {
lib/librte_net/rte_ip.h +2 -1
index 212ff2c4fd..f8a08deed5 100644
@@ -16,7 +16,8 @@
  */
 
 #include <stdint.h>
-#include <sys/types.h>
+
+#include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 
Signature · 1 line
2.29.2
#2 lore raw

PATCH 2/4 ethdev: remove POSIX dependency

In reply to Dmitry Kozlyuk

Use <rte_ip.h> for IP-related defines instead of POSIX headers. Keep <sys/queue.h>, because it is incorporated into DPDK. Cleanup, group, and sort remaining includes per coding style.

---
 lib/librte_ethdev/rte_ethdev.c      | 13 +++++--------
 lib/librte_ethdev/rte_ethdev_core.h |  1 -
 2 files changed, 5 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +5 -8
index 6f514c388b..f363794369 100644
@@ -2,18 +2,15 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
-#include <sys/types.h>
-#include <sys/queue.h>
 #include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include <inttypes.h>
-#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/queue.h>
 
 #include <rte_byteorder.h>
 #include <rte_log.h>
lib/librte_ethdev/rte_ethdev_core.h +0 -1
index 918a34ed1f..4679d948fa 100644
@@ -6,7 +6,6 @@
 #define _RTE_ETHDEV_CORE_H_
 
 #include <pthread.h>
-#include <sys/types.h>
 
 /**
  * @file
Signature · 1 line
2.29.2
#3 lore raw

PATCH 3/4 net/mlx5: remove POSIX dependency

In reply to Dmitry Kozlyuk

Use <rte_ip.h> for IP-related defines instead of POSIX headers. Keep <sys/queue.h>, because it is incorporated into DPDK.

---
 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 -
 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.h +1 -1
index a281fd20ea..f04da06abd 100644
@@ -10,7 +10,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <limits.h>
-#include <netinet/in.h>
+
 #include <sys/queue.h>
 
 #include <rte_pci.h>
drivers/net/mlx5/mlx5_flow.c +2 -2
index ab5be3dacc..73253bd39e 100644
@@ -3,13 +3,13 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#include <netinet/in.h>
-#include <sys/queue.h>
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdbool.h>
 
+#include <sys/queue.h>
+
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <ethdev_driver.h>
drivers/net/mlx5/mlx5_flow.h +2 -2
index 8324e188e1..c4e5f19faa 100644
@@ -5,12 +5,12 @@
 #ifndef RTE_PMD_MLX5_FLOW_H_
 #define RTE_PMD_MLX5_FLOW_H_
 
-#include <netinet/in.h>
-#include <sys/queue.h>
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
 
+#include <sys/queue.h>
+
 #include <rte_alarm.h>
 #include <rte_mtr.h>
 
drivers/net/mlx5/mlx5_mac.c +0 -1
index 6ffcfcd97a..f0450735e2 100644
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <inttypes.h>
 #include <errno.h>
-#include <netinet/in.h>
 
 #include <rte_ether.h>
 #include <ethdev_driver.h>
Signature · 1 line
2.29.2
#4 lore raw

PATCH 4/4 net: replace Windows networking shim

In reply to Dmitry Kozlyuk

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.

---
 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
lib/librte_eal/windows/include/arpa/inet.h deleted +0 -30
deleted file mode 100644
index 96b6984383..0000000000
@@ -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_ */
lib/librte_eal/windows/include/netinet/in.h deleted +0 -38
deleted file mode 100644
index 6455b9ba51..0000000000
@@ -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
lib/librte_eal/windows/include/netinet/ip.h deleted +0 -10
deleted file mode 100644
index 2126498797..0000000000
@@ -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
lib/librte_eal/windows/include/sys/socket.h deleted +0 -24
deleted file mode 100644
index 9536cf8e62..0000000000
@@ -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_ */
lib/librte_net/rte_ether.h +20 -6
index 060b63fc9b..a303c24a8c 100644
@@ -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
lib/librte_net/rte_ip.h +15 -0
index f8a08deed5..6c9904698a 100644
@@ -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>
 
Signature · 1 line
2.29.2
#5 lore raw

v2 cover net: replace Windows networking shim

In reply to Dmitry Kozlyuk

Networking header shim in Windows EAL conflicts with system headers and tries to provide POSIX compatibility out of scope for DPDK. Remove dependency on POSIX headers from libraries supported on Windows, then replace shim with librte_net with workarounds.

A proposed deprecation notice is assumed:
http://patchwork.dpdk.org/project/dpdk/list/?series=15595

v2:
* Fix build on FreeBSD (CI).

Depends-on: series-15513 ("eal/windows: do not expose POSIX symbols")

Dmitry Kozlyuk (4):
cmdline: remove POSIX dependency
ethdev: remove POSIX dependency
net/mlx5: remove POSIX dependency
net: replace Windows networking shim

 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                  |  1 -
 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_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_ethdev/rte_ethdev.c               | 13 +++----
 lib/librte_ethdev/rte_ethdev_core.h          |  1 -
 lib/librte_net/rte_ether.h                   | 26 ++++++++++----
 lib/librte_net/rte_ip.h                      | 17 +++++++++
 19 files changed, 48 insertions(+), 142 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
Signature · 1 line
2.29.2
#6 lore raw

PATCH v2 1/4 cmdline: remove POSIX dependency

Use <rte_ip.h> for IP-related defines instead of POSIX headers.

---
 examples/cmdline/commands.c                  | 1 -
 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_net/rte_ip.h                      | 2 ++
 8 files changed, 3 insertions(+), 19 deletions(-)
examples/cmdline/commands.c +0 -1
index f43eacfbad..2c62d04fb0 100644
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <errno.h>
-#include <netinet/in.h>
 #ifdef RTE_EXEC_ENV_FREEBSD
 #include <sys/socket.h>
 #endif
examples/cmdline/parse_obj_list.c +0 -2
index b04adbea58..959bcd1452 100644
@@ -6,11 +6,9 @@
 
 #include <stdio.h>
 #include <inttypes.h>
-#include <stdarg.h>
 #include <errno.h>
 #include <ctype.h>
 #include <string.h>
-#include <netinet/in.h>
 
 #include <cmdline_parse.h>
 #include <cmdline_parse_ipaddr.h>
lib/librte_cmdline/cmdline.c +0 -1
index 49770869bb..a176d15130 100644
@@ -12,7 +12,6 @@
 #include <inttypes.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <netinet/in.h>
 
 #include <rte_string_fns.h>
 
lib/librte_cmdline/cmdline_parse.c +0 -2
index fe366841cd..f5cc934782 100644
@@ -11,8 +11,6 @@
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <netinet/in.h>
-
 #include <rte_string_fns.h>
 
 #include "cmdline_private.h"
lib/librte_cmdline/cmdline_parse_etheraddr.c +0 -6
index 5cb10de321..433b828a72 100644
@@ -5,13 +5,7 @@
  */
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <ctype.h>
 #include <string.h>
-#include <sys/types.h>
 
 #include <rte_string_fns.h>
 #include <rte_ether.h>
lib/librte_cmdline/cmdline_parse_ipaddr.c +0 -6
index f8dbdf204c..5e278c963f 100644
@@ -6,14 +6,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <ctype.h>
 #include <string.h>
 #include <errno.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
 
 #include <rte_string_fns.h>
 
lib/librte_cmdline/cmdline_parse_ipaddr.h +1 -1
index 0ba81647bc..0118c31d44 100644
@@ -8,7 +8,7 @@
 #define _PARSE_IPADDR_H_
 
 #include <cmdline_parse.h>
-#include <netinet/in.h>
+#include <rte_ip.h>
 
 #ifdef __cplusplus
 extern "C" {
lib/librte_net/rte_ip.h +2 -0
index 212ff2c4fd..3ab4de2ec0 100644
@@ -16,7 +16,9 @@
  */
 
 #include <stdint.h>
+
 #include <sys/types.h>
+#include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 
Signature · 1 line
2.29.2
#7 lore raw

PATCH v2 2/4 ethdev: remove POSIX dependency

In reply to Dmitry Kozlyuk

Use <rte_ip.h> for IP-related defines instead of POSIX headers. Keep <sys/queue.h>, because it is incorporated into DPDK. Cleanup, group, and sort remaining includes per coding style.

---
 lib/librte_ethdev/rte_ethdev.c      | 13 +++++--------
 lib/librte_ethdev/rte_ethdev_core.h |  1 -
 2 files changed, 5 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +5 -8
index 6f514c388b..f363794369 100644
@@ -2,18 +2,15 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
-#include <sys/types.h>
-#include <sys/queue.h>
 #include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include <inttypes.h>
-#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/queue.h>
 
 #include <rte_byteorder.h>
 #include <rte_log.h>
lib/librte_ethdev/rte_ethdev_core.h +0 -1
index 918a34ed1f..4679d948fa 100644
@@ -6,7 +6,6 @@
 #define _RTE_ETHDEV_CORE_H_
 
 #include <pthread.h>
-#include <sys/types.h>
 
 /**
  * @file
Signature · 1 line
2.29.2
#8 lore raw

PATCH v2 3/4 net/mlx5: remove POSIX dependency

In reply to Dmitry Kozlyuk

Use <rte_ip.h> for IP-related defines instead of POSIX headers. Keep <sys/queue.h>, because it is incorporated into DPDK.

---
 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 -
 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.h +1 -1
index a281fd20ea..f04da06abd 100644
@@ -10,7 +10,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <limits.h>
-#include <netinet/in.h>
+
 #include <sys/queue.h>
 
 #include <rte_pci.h>
drivers/net/mlx5/mlx5_flow.c +2 -2
index ab5be3dacc..73253bd39e 100644
@@ -3,13 +3,13 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#include <netinet/in.h>
-#include <sys/queue.h>
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdbool.h>
 
+#include <sys/queue.h>
+
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <ethdev_driver.h>
drivers/net/mlx5/mlx5_flow.h +2 -2
index 8324e188e1..c4e5f19faa 100644
@@ -5,12 +5,12 @@
 #ifndef RTE_PMD_MLX5_FLOW_H_
 #define RTE_PMD_MLX5_FLOW_H_
 
-#include <netinet/in.h>
-#include <sys/queue.h>
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
 
+#include <sys/queue.h>
+
 #include <rte_alarm.h>
 #include <rte_mtr.h>
 
drivers/net/mlx5/mlx5_mac.c +0 -1
index 6ffcfcd97a..f0450735e2 100644
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <inttypes.h>
 #include <errno.h>
-#include <netinet/in.h>
 
 #include <rte_ether.h>
 #include <ethdev_driver.h>
Signature · 1 line
2.29.2
#9 lore raw

PATCH v2 4/4 net: replace Windows networking shim

In reply to Dmitry Kozlyuk

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.

---
 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
lib/librte_eal/windows/include/arpa/inet.h deleted +0 -30
deleted file mode 100644
index 96b6984383..0000000000
@@ -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_ */
lib/librte_eal/windows/include/netinet/in.h deleted +0 -38
deleted file mode 100644
index 6455b9ba51..0000000000
@@ -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
lib/librte_eal/windows/include/netinet/ip.h deleted +0 -10
deleted file mode 100644
index 2126498797..0000000000
@@ -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
lib/librte_eal/windows/include/sys/socket.h deleted +0 -24
deleted file mode 100644
index 9536cf8e62..0000000000
@@ -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_ */
lib/librte_net/rte_ether.h +20 -6
index 060b63fc9b..a303c24a8c 100644
@@ -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
lib/librte_net/rte_ip.h +15 -0
index 3ab4de2ec0..8c138c1b91 100644
@@ -17,11 +17,26 @@
 
 #include <stdint.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+
 #include <sys/types.h>
 #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>
 
Signature · 1 line
2.29.2
#10 lore raw

v3 cover net: replace Windows networking shim

In reply to Dmitry Kozlyuk

Networking header shim in Windows EAL conflicts with system headers and tries to provide POSIX compatibility out of scope for DPDK. Remove dependency on POSIX headers from libraries supported on Windows, then replace shim with librte_net with workarounds.

A proposed deprecation notice is assumed:
http://patchwork.dpdk.org/project/dpdk/list/?series=15595

v3: Fix build on FreeBSD for real (CI).
v2: Fix build on FreeBSD (CI).

Depends-on: series-15513 ("eal/windows: do not expose POSIX symbols")

Dmitry Kozlyuk (4):
cmdline: remove POSIX dependency
ethdev: remove POSIX dependency
net/mlx5: remove POSIX dependency
net: replace Windows networking shim

 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                  |  1 -
 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_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_ethdev/rte_ethdev.c               | 13 +++----
 lib/librte_ethdev/rte_ethdev_core.h          |  1 -
 lib/librte_net/rte_ether.h                   | 26 ++++++++++----
 lib/librte_net/rte_ip.h                      | 18 ++++++++++
 19 files changed, 49 insertions(+), 142 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
Signature · 1 line
2.29.2
#11 lore raw

PATCH v3 1/4 cmdline: remove POSIX dependency

Use <rte_ip.h> for IP-related defines instead of POSIX headers.

---
Depends-on: series-15513 ("eal/windows: do not expose POSIX symbols")

 examples/cmdline/commands.c                  | 1 -
 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_net/rte_ip.h                      | 3 +++
 8 files changed, 4 insertions(+), 19 deletions(-)
examples/cmdline/commands.c +0 -1
index f43eacfbad..2c62d04fb0 100644
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <errno.h>
-#include <netinet/in.h>
 #ifdef RTE_EXEC_ENV_FREEBSD
 #include <sys/socket.h>
 #endif
examples/cmdline/parse_obj_list.c +0 -2
index b04adbea58..959bcd1452 100644
@@ -6,11 +6,9 @@
 
 #include <stdio.h>
 #include <inttypes.h>
-#include <stdarg.h>
 #include <errno.h>
 #include <ctype.h>
 #include <string.h>
-#include <netinet/in.h>
 
 #include <cmdline_parse.h>
 #include <cmdline_parse_ipaddr.h>
lib/librte_cmdline/cmdline.c +0 -1
index 49770869bb..a176d15130 100644
@@ -12,7 +12,6 @@
 #include <inttypes.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <netinet/in.h>
 
 #include <rte_string_fns.h>
 
lib/librte_cmdline/cmdline_parse.c +0 -2
index fe366841cd..f5cc934782 100644
@@ -11,8 +11,6 @@
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <netinet/in.h>
-
 #include <rte_string_fns.h>
 
 #include "cmdline_private.h"
lib/librte_cmdline/cmdline_parse_etheraddr.c +0 -6
index 5cb10de321..433b828a72 100644
@@ -5,13 +5,7 @@
  */
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <ctype.h>
 #include <string.h>
-#include <sys/types.h>
 
 #include <rte_string_fns.h>
 #include <rte_ether.h>
lib/librte_cmdline/cmdline_parse_ipaddr.c +0 -6
index f8dbdf204c..5e278c963f 100644
@@ -6,14 +6,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <ctype.h>
 #include <string.h>
 #include <errno.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
 
 #include <rte_string_fns.h>
 
lib/librte_cmdline/cmdline_parse_ipaddr.h +1 -1
index 0ba81647bc..0118c31d44 100644
@@ -8,7 +8,7 @@
 #define _PARSE_IPADDR_H_
 
 #include <cmdline_parse.h>
-#include <netinet/in.h>
+#include <rte_ip.h>
 
 #ifdef __cplusplus
 extern "C" {
lib/librte_net/rte_ip.h +3 -0
index 212ff2c4fd..2cf7b0bd28 100644
@@ -16,7 +16,10 @@
  */
 
 #include <stdint.h>
+
+#include <sys/socket.h>
 #include <sys/types.h>
+#include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 
Signature · 1 line
2.29.2
#13 lore raw

PATCH v3 2/4 ethdev: remove POSIX dependency

In reply to Dmitry Kozlyuk

Use <rte_ip.h> for IP-related defines instead of POSIX headers. Keep <sys/queue.h>, because it is incorporated into DPDK. Cleanup, group, and sort remaining includes per coding style.

---
 lib/librte_ethdev/rte_ethdev.c      | 13 +++++--------
 lib/librte_ethdev/rte_ethdev_core.h |  1 -
 2 files changed, 5 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +5 -8
index 6f514c388b..f363794369 100644
@@ -2,18 +2,15 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
-#include <sys/types.h>
-#include <sys/queue.h>
 #include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include <inttypes.h>
-#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/queue.h>
 
 #include <rte_byteorder.h>
 #include <rte_log.h>
lib/librte_ethdev/rte_ethdev_core.h +0 -1
index 918a34ed1f..4679d948fa 100644
@@ -6,7 +6,6 @@
 #define _RTE_ETHDEV_CORE_H_
 
 #include <pthread.h>
-#include <sys/types.h>
 
 /**
  * @file
Signature · 1 line
2.29.2
#15 lore raw

PATCH v3 3/4 net/mlx5: remove POSIX dependency

In reply to Dmitry Kozlyuk

Use <rte_ip.h> for IP-related defines instead of POSIX headers. Keep <sys/queue.h>, because it is incorporated into DPDK.

---
 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 -
 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.h +1 -1
index a281fd20ea..f04da06abd 100644
@@ -10,7 +10,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <limits.h>
-#include <netinet/in.h>
+
 #include <sys/queue.h>
 
 #include <rte_pci.h>
drivers/net/mlx5/mlx5_flow.c +2 -2
index ab5be3dacc..73253bd39e 100644
@@ -3,13 +3,13 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#include <netinet/in.h>
-#include <sys/queue.h>
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdbool.h>
 
+#include <sys/queue.h>
+
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <ethdev_driver.h>
drivers/net/mlx5/mlx5_flow.h +2 -2
index 8324e188e1..c4e5f19faa 100644
@@ -5,12 +5,12 @@
 #ifndef RTE_PMD_MLX5_FLOW_H_
 #define RTE_PMD_MLX5_FLOW_H_
 
-#include <netinet/in.h>
-#include <sys/queue.h>
 #include <stdalign.h>
 #include <stdint.h>
 #include <string.h>
 
+#include <sys/queue.h>
+
 #include <rte_alarm.h>
 #include <rte_mtr.h>
 
drivers/net/mlx5/mlx5_mac.c +0 -1
index 6ffcfcd97a..f0450735e2 100644
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <inttypes.h>
 #include <errno.h>
-#include <netinet/in.h>
 
 #include <rte_ether.h>
 #include <ethdev_driver.h>
Signature · 1 line
2.29.2
#17 lore raw

PATCH v3 4/4 net: replace Windows networking shim

In reply to Dmitry Kozlyuk

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.

---
 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
lib/librte_eal/windows/include/arpa/inet.h deleted +0 -30
deleted file mode 100644
index 96b6984383..0000000000
@@ -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_ */
lib/librte_eal/windows/include/netinet/in.h deleted +0 -38
deleted file mode 100644
index 6455b9ba51..0000000000
@@ -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
lib/librte_eal/windows/include/netinet/ip.h deleted +0 -10
deleted file mode 100644
index 2126498797..0000000000
@@ -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
lib/librte_eal/windows/include/sys/socket.h deleted +0 -24
deleted file mode 100644
index 9536cf8e62..0000000000
@@ -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_ */
lib/librte_net/rte_ether.h +20 -6
index 060b63fc9b..a303c24a8c 100644
@@ -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
lib/librte_net/rte_ip.h +15 -0
index 2cf7b0bd28..87fbc26431 100644
@@ -17,12 +17,27 @@
 
 #include <stdint.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+
 #include <sys/socket.h>
 #include <sys/types.h>
 #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>
 
Signature · 1 line
2.29.2
#18 lore raw
In reply to Dmitry Kozlyuk
Quoted 11 lines · Dmitry Kozlyuk

Networking header shim in Windows EAL conflicts with system headers and tries to provide POSIX compatibility out of scope for DPDK. Remove dependency on POSIX headers from libraries supported on Windows, then replace shim with librte_net with workarounds.

A proposed deprecation notice is assumed:
http://patchwork.dpdk.org/project/dpdk/list/?series=15595

v3: Fix build on FreeBSD for real (CI).
v2: Fix build on FreeBSD (CI).

Quoted 8 lines

Depends-on: series-15513 ("eal/windows: do not expose POSIX symbols")

Dmitry Kozlyuk (4):
cmdline: remove POSIX dependency
ethdev: remove POSIX dependency
net/mlx5: remove POSIX dependency
net: replace Windows networking shim

Hi Dmitry,

Have you seen the CI reported build errors:
http://mails.dpdk.org/archives/test-report/2021-March/182361.html

Briefly:
./lib/librte_net/rte_net.c:132:7: error: 'IPPROTO_GRE' undeclared ./lib/librte_net/rte_net.c:163:7: error: 'IPPROTO_IPIP' undeclared

#19 lore raw
Quoted 3 lines

Hi Ferruh,

Quoted 1 line

Have you seen the CI reported build errors:

Quoted 6 lines

http://mails.dpdk.org/archives/test-report/2021-March/182361.html

Briefly:
./lib/librte_net/rte_net.c:132:7: error: 'IPPROTO_GRE' undeclared ./lib/librte_net/rte_net.c:163:7: error: 'IPPROTO_IPIP' undeclared

This is because CI doesn't apply patches in Depends-on. In this case, missing constants would be defined when RTE_BUILD_INTERNAL is defined (so that symbols are only visible to DPDK), and it is introduced by dependency series.

Quoted 1 line
Acked-by on the v3 series
#20 lore raw
In reply to Dmitry Kozlyuk
Quoted 39 lines · Dmitry Kozlyuk

Networking header shim in Windows EAL conflicts with system headers and tries to provide POSIX compatibility out of scope for DPDK. Remove dependency on POSIX headers from libraries supported on Windows, then replace shim with librte_net with workarounds.

A proposed deprecation notice is assumed:
http://patchwork.dpdk.org/project/dpdk/list/?series=15595

v3: Fix build on FreeBSD for real (CI).
v2: Fix build on FreeBSD (CI).

Depends-on: series-15513 ("eal/windows: do not expose POSIX symbols")

Dmitry Kozlyuk (4):
cmdline: remove POSIX dependency
ethdev: remove POSIX dependency
net/mlx5: remove POSIX dependency
net: replace Windows networking shim

  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                  |  1 -
  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_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_ethdev/rte_ethdev.c               | 13 +++----
  lib/librte_ethdev/rte_ethdev_core.h          |  1 -
  lib/librte_net/rte_ether.h                   | 26 ++++++++++----
  lib/librte_net/rte_ip.h                      | 18 ++++++++++
  19 files changed, 49 insertions(+), 142 deletions(-)
Quoted 5 lines

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