eal/windows: do not expose POSIX symbols
Subsystems (2)
PATCH v10 2/4 eal: make OS shims internal
In reply to Dmitry KozlyukDPDK 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 <rte_os.h> provided macros or inline definitions for such symbols. However, when placed in public header, these symbols were unnecessarily exposed, breaking consumer POSIX compatibility code.
Move most of the shims to <rte_os_shim.h>, a header to be used instead of <rte_os.h> by internal code. Include it in libraries and PMDs that previously imported shims from <rte_os.h>. Directly replace shims that were only used inside EAL:
* index -> strchr, rindex -> strrchr
* sleep -> rte_delay_us_sleep
* strerror_r -> strerror_s
Remove sleep(3) shim in favour of rte_delay_us_sleep().
--- drivers/bus/pci/private.h | 4 +- drivers/bus/vdev/vdev_private.h | 2 + drivers/common/mlx5/mlx5_common.h | 1 + drivers/net/i40e/i40e_ethdev.c | 1 + examples/service_cores/main.c | 4 +- lib/librte_cmdline/cmdline.c | 4 -- lib/librte_cmdline/cmdline_os_windows.c | 2 - lib/librte_cmdline/cmdline_private.h | 1 + lib/librte_cmdline/cmdline_socket.c | 4 -- lib/librte_eal/common/eal_common_config.c | 1 - lib/librte_eal/common/eal_common_errno.c | 4 ++ lib/librte_eal/common/eal_common_log.c | 1 + lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/common/eal_common_timer.c | 4 +- lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/freebsd/include/rte_os_shim.h | 14 +++++ lib/librte_eal/linux/include/rte_os_shim.h | 14 +++++ lib/librte_eal/windows/eal_hugepages.c | 1 - lib/librte_eal/windows/eal_lcore.c | 1 - lib/librte_eal/windows/eal_memalloc.c | 1 - lib/librte_eal/windows/include/rte_os.h | 62 ++------------------ lib/librte_eal/windows/include/rte_os_shim.h | 28 +++++++++ lib/librte_ethdev/ethdev_private.h | 2 + lib/librte_kvargs/rte_kvargs.c | 1 + 24 files changed, 82 insertions(+), 78 deletions(-) create mode 100644 lib/librte_eal/freebsd/include/rte_os_shim.h create mode 100644 lib/librte_eal/linux/include/rte_os_shim.h create mode 100644 lib/librte_eal/windows/include/rte_os_shim.h
drivers/bus/pci/private.h +3 -1
@@ -7,8 +7,10 @@#include <stdbool.h> #include <stdio.h> -#include <rte_pci.h> +#include <rte_bus_pci.h> +#include <rte_os_shim.h> +#include <rte_pci.h> extern struct rte_pci_bus rte_pci_bus;
drivers/bus/vdev/vdev_private.h +2 -0
@@ -5,6 +5,8 @@ #ifndef _VDEV_PRIVATE_H_ #define _VDEV_PRIVATE_H_ +#include <rte_os_shim.h> + #ifdef __cplusplus extern "C" { #endif
drivers/common/mlx5/mlx5_common.h +1 -0
@@ -14,6 +14,7 @@#include <rte_kvargs.h> #include <rte_devargs.h> #include <rte_bitops.h> +#include <rte_os_shim.h> #include "mlx5_prm.h" #include "mlx5_devx_cmds.h"
drivers/net/i40e/i40e_ethdev.c +1 -0
@@ -27,6 +27,7 @@#include <rte_tailq.h> #include <rte_hash_crc.h> #include <rte_bitmap.h> +#include <rte_os_shim.h> #include "i40e_logs.h" #include "base/i40e_prototype.h"
examples/service_cores/main.c +2 -2
@@ -209,10 +209,10 @@ main(int argc, char **argv)apply_profile (i);printf ("\n==> Profile: %s\n\n" , profiles[i].name); -sleep (1 ); +rte_delay_us_sleep (1 *US_PER_S );rte_service_dump (stdout,UINT32_MAX ); -sleep (5 ); +rte_delay_us_sleep (5 *US_PER_S );rte_service_dump (stdout,UINT32_MAX ); i++;
lib/librte_cmdline/cmdline.c +0 -4
@@ -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)
lib/librte_cmdline/cmdline_os_windows.c +0 -2
@@ -4,8 +4,6 @@#include <io.h> -#include <rte_os.h> -#include "cmdline_private.h" /* Missing from some MinGW-w64 distributions. */
lib/librte_cmdline/cmdline_private.h +1 -0
@@ -8,6 +8,7 @@#include <stdarg.h> #include <rte_common.h> +#include <rte_os_shim.h> #ifdef RTE_EXEC_ENV_WINDOWS #include <rte_windows.h> #endif
lib/librte_cmdline/cmdline_socket.c +0 -4
@@ -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) {
lib/librte_eal/common/eal_common_config.c +0 -1
@@ -3,7 +3,6 @@*/ #include <string.h> -#include <rte_os.h> #include <rte_string_fns.h> #include "eal_private.h"
lib/librte_eal/common/eal_common_errno.c +4 -0
@@ -15,6 +15,10 @@#include <rte_errno.h> #include <rte_string_fns.h> +#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 *
lib/librte_eal/common/eal_common_log.c +1 -0
@@ -13,6 +13,7 @@#include <rte_eal.h> #include <rte_log.h> +#include <rte_os_shim.h> #include <rte_per_lcore.h> #include "eal_log.h"
lib/librte_eal/common/eal_common_options.c +1 -1
@@ -1959,7 +1959,7 @@ eal_check_common_options(struct internal_config *internal_cfg)RTE_LOG (ERR ,EAL ,"Invalid length of --" OPT_MBUF_POOL_OPS_NAME " option\n" );return -1 ; } -if (index (eal_get_hugefile_prefix (),'%' ) !=NULL ) { +if (strchr (eal_get_hugefile_prefix (),'%' ) !=NULL ) {RTE_LOG (ERR ,EAL ,"Invalid char, '%%', in --" OPT_FILE_PREFIX " " "option\n" );return -1 ;
lib/librte_eal/common/eal_common_timer.c +2 -2
@@ -47,9 +47,9 @@ estimate_tsc_freq(void)#define CYC_PER_10MHZ 1E7RTE_LOG (WARNING ,EAL ,"WARNING: TSC frequency estimated roughly" " - clock timings may be less accurate.\n" ); -/* assume that the sleep(1) will sleep for 1 second */ +/* assume that the rte_delay_us_sleep() will sleep for 1 second */ uint64_t start =rte_rdtsc (); -sleep (1 ); +rte_delay_us_sleep (US_PER_S );/* Round up to 10Mhz. 1E7 ~ 10Mhz */ return RTE_ALIGN_MUL_NEAR (rte_rdtsc () - start,CYC_PER_10MHZ ); }
lib/librte_eal/common/eal_internal_cfg.h +1 -0
@@ -11,6 +11,7 @@#define EAL_INTERNAL_CFG_H #include <rte_eal.h> +#include <rte_os_shim.h> #include <rte_pci_dev_feature_defs.h> #include "eal_thread.h"
lib/librte_eal/freebsd/include/rte_os_shim.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_SHIM_ +#define _RTE_OS_SHIM_ + +#include <rte_os.h> + +/** +* @file +* @internal +* Provides semi-standard OS facilities by convenient names. +*/ + +#endif /* _RTE_OS_SHIM_ */
lib/librte_eal/linux/include/rte_os_shim.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_SHIM_ +#define _RTE_OS_SHIM_ + +#include <rte_os.h> + +/** +* @file +* @internal +* Provides semi-standard OS facilities by convenient names. +*/ + +#endif /* _RTE_OS_SHIM_ */
lib/librte_eal/windows/eal_hugepages.c +0 -1
@@ -6,7 +6,6 @@#include <rte_log.h> #include <rte_memory.h> #include <rte_memzone.h> -#include <rte_os.h> #include "eal_private.h" #include "eal_filesystem.h"
lib/librte_eal/windows/eal_lcore.c +0 -1
@@ -9,7 +9,6 @@#include <rte_common.h> #include <rte_debug.h> #include <rte_lcore.h> -#include <rte_os.h> #include "eal_private.h" #include "eal_thread.h"
lib/librte_eal/windows/eal_memalloc.c +0 -1
@@ -3,7 +3,6 @@*/ #include <rte_errno.h> -#include <rte_os.h> #include "eal_internal_cfg.h" #include "eal_memalloc.h"
lib/librte_eal/windows/include/rte_os.h +4 -58
76 lines not on this page · raw message
lib/librte_eal/windows/include/rte_os_shim.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_SHIM_ +#define _RTE_OS_SHIM_ + +#include <rte_os.h> + +/** +* @file +* @internal +* Provides semi-standard OS facilities by convenient names. +*/ + +#ifndef PATH_MAX +#define PATH_MAX _MAX_PATH +#endif + +#define strdup (str) _strdup(str) +#define strtok_r (str, delim, saveptr) strtok_s(str, delim, saveptr) +#define strncasecmp (s1, s2, count) _strnicmp(s1, s2, count) + +#define open (path, flags, ...) _open(path, flags, ##__VA_ARGS__) +#define read (fd, buf, n) _read(fd, buf, n) +#define write (fd, buf, n) _write(fd, buf, n) +#define close (fd) _close(fd) +#define unlink (path) _unlink(path) + +#endif /* _RTE_OS_SHIM_ */
lib/librte_ethdev/ethdev_private.h +2 -0
@@ -5,6 +5,8 @@#ifndef _ETH_PRIVATE_H_#define _ETH_PRIVATE_H_ +#include <rte_os_shim.h> +#include "rte_ethdev.h" #ifdef __cplusplus
lib/librte_kvargs/rte_kvargs.c +1 -0
@@ -7,6 +7,7 @@#include <stdlib.h> #include <stdbool.h> +#include <rte_os_shim.h> #include <rte_string_fns.h> #include "rte_kvargs.h"
Signature · 1 line
2.29.3
PATCH v10 3/4 net: work around s_addr macro on Windows
In reply to Dmitry KozlyukWindows Sockets headers contain #define s_addr S_un.S_addr, which conflicts with definition of s_addr field of struct rte_ether_hdr. Prieviously s_addr was undefined in <rte_ether.h>, which had been breaking access to s_addr field of struct in_addr, so some DPDK and Windows headers could not be included in one file.
Renaming of struct rte_ether_hdr is planned:
https://mails.dpdk.org/archives/dev/2021-March/201444.html
Temporarily disable s_addr macro around struct rte_ether_hdr definition to avoid conflict. Place source MAC address in both s_addr and S_un.S_addr fields, so that access works either directly or through the macro as defined in Windows headers.
--- lib/librte_net/rte_ether.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
lib/librte_net/rte_ether.h +20 -6
@@ -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_experimentalint 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
Signature · 1 line
2.29.3
PATCH v10 4/4 net: provide IP-related API on any OS
In reply to Dmitry KozlyukUsers of <rte_ip.h> relied on it to provide IP-related defines, like IPPROTO_* constants, but still had to include POSIX headers for inet_pton() and other standard IP-related facilities.
Extend <rte_ip.h> so that it is a single header to gain access to IP-related facilities on any OS. Use it to replace POSIX includes in components enabled on Windows. Move missing constants from Windows networking shim to OS shim header and include it where needed.
Remove Windows networking shim that is no longer needed.
--- drivers/net/i40e/i40e_fdir.c | 1 + drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow.c | 4 +-- drivers/net/mlx5/mlx5_flow.h | 3 +- drivers/net/mlx5/mlx5_mac.c | 1 - examples/cmdline/commands.c | 5 --- examples/cmdline/parse_obj_list.c | 2 -- examples/flow_filtering/main.c | 1 - examples/l2fwd/main.c | 1 - examples/link_status_interrupt/main.c | 1 - lib/librte_cmdline/cmdline.c | 1 - lib/librte_cmdline/cmdline_parse.c | 2 -- lib/librte_cmdline/cmdline_parse_etheraddr.c | 6 ---- lib/librte_cmdline/cmdline_parse_ipaddr.c | 6 ---- lib/librte_cmdline/cmdline_parse_ipaddr.h | 2 +- lib/librte_eal/windows/include/arpa/inet.h | 30 ---------------- lib/librte_eal/windows/include/netinet/in.h | 38 -------------------- lib/librte_eal/windows/include/netinet/ip.h | 10 ------ lib/librte_eal/windows/include/rte_os_shim.h | 8 +++++ lib/librte_eal/windows/include/sys/socket.h | 24 ------------- lib/librte_ethdev/rte_ethdev.c | 12 +++---- lib/librte_ethdev/rte_ethdev_core.h | 1 - lib/librte_net/rte_ip.h | 7 ++++ lib/librte_net/rte_net.c | 1 + 24 files changed, 24 insertions(+), 144 deletions(-) delete mode 100644 lib/librte_eal/windows/include/arpa/inet.h delete mode 100644 lib/librte_eal/windows/include/netinet/in.h delete mode 100644 lib/librte_eal/windows/include/netinet/ip.h delete mode 100644 lib/librte_eal/windows/include/sys/socket.h
drivers/net/i40e/i40e_fdir.c +1 -0
@@ -22,6 +22,7 @@#include <rte_sctp.h> #include <rte_hash_crc.h> #include <rte_bitmap.h> +#include <rte_os_shim.h> #include "i40e_logs.h" #include "base/i40e_type.h"
drivers/net/mlx5/mlx5.h +0 -1
@@ -10,7 +10,6 @@#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 +1 -3
@@ -3,12 +3,11 @@* 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>
@@ -8241,4 +8240,3 @@ mlx5_release_tunnel_hub(__rte_unused struct mlx5_dev_ctx_shared *sh, { }#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -
drivers/net/mlx5/mlx5_flow.h +1 -2
@@ -5,11 +5,10 @@#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
@@ -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>
examples/cmdline/commands.c +0 -5
@@ -8,12 +8,7 @@#include <stdint.h> #include <string.h> #include <stdlib.h> -#include <stdarg.h> #include <errno.h> -#include <netinet/in.h> -#ifdef RTE_EXEC_ENV_FREEBSD -#include <sys/socket.h> -#endif #include <cmdline_rdline.h> #include <cmdline_parse.h>
examples/cmdline/parse_obj_list.c +0 -2
@@ -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>
examples/flow_filtering/main.c +0 -1
@@ -9,7 +9,6 @@#include <inttypes.h> #include <sys/types.h> #include <sys/queue.h> -#include <netinet/in.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
examples/l2fwd/main.c +0 -1
@@ -9,7 +9,6 @@#include <inttypes.h> #include <sys/types.h> #include <sys/queue.h> -#include <netinet/in.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
examples/link_status_interrupt/main.c +0 -1
@@ -9,7 +9,6 @@#include <inttypes.h> #include <sys/types.h> #include <sys/queue.h> -#include <netinet/in.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
lib/librte_cmdline/cmdline.c +0 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -8,7 +8,7 @@#define _PARSE_IPADDR_H_#include <cmdline_parse.h> -#include <netinet/in.h> +#include <rte_ip.h> #ifdef __cplusplusextern "C" {
lib/librte_eal/windows/include/arpa/inet.h deleted +0 -30
@@ -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
@@ -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
@@ -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/rte_os_shim.h +8 -0
@@ -25,4 +25,12 @@#define close (fd) _close(fd)#define unlink (path) _unlink(path) +#define IPVERSION 4 + +#define IPPROTO_IPIP 4 +#define IPPROTO_GRE 47 +#ifdef RTE_TOOLCHAIN_GCC +#define IPPROTO_SCTP 132 +#endif +#endif /* _RTE_OS_SHIM_ */
lib/librte_eal/windows/include/sys/socket.h deleted +0 -24
@@ -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_ethdev/rte_ethdev.c +4 -8
@@ -2,18 +2,14 @@* 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
@@ -6,7 +6,6 @@#define _RTE_ETHDEV_CORE_H_#include <pthread.h> -#include <sys/types.h> /** * @file
lib/librte_net/rte_ip.h +7 -0
@@ -16,9 +16,16 @@*/ #include <stdint.h> + +#ifdef RTE_EXEC_ENV_WINDOWS +#include <ws2tcpip.h> +#else +#include <sys/socket.h> #include <sys/types.h> +#include <arpa/inet.h> #include <netinet/in.h> #include <netinet/ip.h> +#endif #include <rte_byteorder.h> #include <rte_mbuf.h>
lib/librte_net/rte_net.c +1 -0
@@ -15,6 +15,7 @@#include <rte_gre.h> #include <rte_mpls.h> #include <rte_net.h> +#include <rte_os_shim.h> /* get l3 packet type from ip6 next protocol */ static uint32_t
Signature · 1 line
2.29.3
Quoted 70 lines · Dmitry Kozlyuk
On Windows, EAL contains two sets of functions and macros for POSIX
compatibility: <rte_os.h> and a networking shim (socket headers). The latter conflicts with system headers and should not exist. Exposing the former from EAL can break consumer own POSIX compatibility layer and is against standards in general. Hide these symbols from external consumers, while keeping them available for DPDK code.v10:
* Fix examples that build on Windows.
v9:
* Fix missing <rte_os_shim.h> include inrte_common_log.c. (This will happen again. Going to add a checkpatch test after this series is merged.)Dmitry Kozlyuk (4):
eal/windows: hideasprintf()shim
eal: make OS shims internal
net: work arounds_addrmacro on Windows
net: provide IP-related API on any OSdrivers/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 + drivers/net/i40e/i40e_fdir.c | 1 + drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 3 +- drivers/net/mlx5/mlx5_mac.c | 1 - examples/cmdline/commands.c | 5 -- examples/cmdline/parse_obj_list.c | 2 - examples/flow_filtering/main.c | 1 - examples/l2fwd/main.c | 1 - examples/link_status_interrupt/main.c | 1 - examples/service_cores/main.c | 4 +- lib/librte_cmdline/cmdline.c | 5 -- lib/librte_cmdline/cmdline_os_windows.c | 2 - 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_cmdline/cmdline_private.h | 1 + lib/librte_cmdline/cmdline_socket.c | 4 - lib/librte_eal/common/eal_common_config.c | 1 - lib/librte_eal/common/eal_common_errno.c | 4 + lib/librte_eal/common/eal_common_log.c | 1 + lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/common/eal_common_timer.c | 4 +- lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_private.h | 11 +++ lib/librte_eal/freebsd/include/rte_os_shim.h | 14 +++ lib/librte_eal/linux/include/rte_os_shim.h | 14 +++ lib/librte_eal/windows/eal.c | 30 +++++++ 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/arpa/inet.h | 30 ------- lib/librte_eal/windows/include/netinet/in.h | 38 -------- lib/librte_eal/windows/include/netinet/ip.h | 10 --- lib/librte_eal/windows/include/rte_os.h | 92 +------------------- lib/librte_eal/windows/include/rte_os_shim.h | 36 ++++++++ lib/librte_eal/windows/include/sys/socket.h | 24 ----- lib/librte_ethdev/ethdev_private.h | 2 + lib/librte_ethdev/rte_ethdev.c | 12 +-- lib/librte_ethdev/rte_ethdev_core.h | 1 - lib/librte_kvargs/rte_kvargs.c | 1 + lib/librte_net/rte_ether.h | 26 ++++-- lib/librte_net/rte_ip.h | 7 ++ lib/librte_net/rte_net.c | 1 + 49 files changed, 167 insertions(+), 258 deletions(-)
Quoted 7 lines
create mode 100644
lib/librte_eal/freebsd/include/rte_os_shim.hcreate mode 100644lib/librte_eal/linux/include/rte_os_shim.hdelete mode 100644lib/librte_eal/windows/include/arpa/inet.hdelete mode 100644lib/librte_eal/windows/include/netinet/in.hdelete mode 100644lib/librte_eal/windows/include/netinet/ip.hcreate mode 100644lib/librte_eal/windows/include/rte_os_shim.hdelete mode 100644lib/librte_eal/windows/include/sys/socket.h
Thanks, Dmitry.
Thomas Monjalon
AppliedQuoted 9 lines
Quoted 5 lines
Dmitry Kozlyuk (4):
eal/windows: hideasprintf()shim
eal: make OS shims internal
net: work arounds_addrmacro on Windows
net: provide IP-related API on any OSThanks, Dmitry.
Acked-by Ranjit Menon <[email protected]>
Applied, thanks
Quoted 52 lines · Dmitry Kozlyuk
On Windows,
rte_os.hcontains a small POSIX compatibility set of functions and macros. Exposing it from EAL can break consumer own POSIX compatibility layer and is against standards in general.First define required wrappers, then fix POSIX dependencies in Windows-enabled libraries and drivers, then eliminate POSIX symbols from Windows EAL API. Commits are arranged so that they all compile and are limited in scope; patches 5, 6, 7 can be squashed if needed.
No "Fixes" tags, because it's really an enhancement, preventing issues rather then solving direct ones.
Dmitry Kozlyuk (7):
eal: add wrappers for POSIX string functions
eal: add macro for maximum path length
eal: add sleep API
eal: addasprintf()internal wrapper
lib: remove POSIX dependencies
drivers: remove POSIX dependencies
eal/windows: do not expose POSIX symbolsdoc/guides/rel_notes/release_21_05.rst | 9 ++ drivers/bus/pci/private.h | 2 +- drivers/bus/vdev/vdev.c | 4 +- drivers/bus/vdev/vdev_params.c | 3 +- drivers/common/mlx5/mlx5_common_pci.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 56 +++++------ lib/librte_cmdline/cmdline.c | 1 + lib/librte_eal/common/eal_common_config.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 6 +- lib/librte_eal/common/eal_common_devargs.c | 7 +- lib/librte_eal/common/eal_common_errno.c | 4 + lib/librte_eal/common/eal_common_fbarray.c | 8 +- lib/librte_eal/common/eal_common_lcore.c | 2 +- lib/librte_eal/common/eal_common_log.c | 5 +- lib/librte_eal/common/eal_common_options.c | 42 ++++---- lib/librte_eal/common/eal_common_timer.c | 5 +- lib/librte_eal/common/eal_common_trace.c | 2 +- lib/librte_eal/common/eal_common_trace_ctf.c | 4 +- .../common/eal_common_trace_utils.c | 13 +-- lib/librte_eal/common/eal_filesystem.h | 8 +- lib/librte_eal/common/eal_hugepages.h | 2 +- lib/librte_eal/common/eal_internal_cfg.h | 2 +- lib/librte_eal/common/eal_private.h | 23 +++++ lib/librte_eal/common/eal_trace.h | 2 +- lib/librte_eal/freebsd/include/rte_os.h | 6 +- lib/librte_eal/include/rte_string_fns.h | 42 ++++++++ lib/librte_eal/include/rte_thread.h | 11 +++ lib/librte_eal/linux/include/rte_os.h | 6 +- lib/librte_eal/rte_eal_exports.def | 2 + lib/librte_eal/unix/rte_thread.c | 6 ++ lib/librte_eal/version.map | 3 +
Quoted 9 lines
lib/librte_eal/windows/eal.c | 30 ++++++ lib/librte_eal/windows/eal_thread.c | 9 +- lib/librte_eal/windows/include/dirent.h | 21 ++-- lib/librte_eal/windows/include/rte_os.h | 99 ++----------------- lib/librte_ethdev/rte_class_eth.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 2 +- lib/librte_kvargs/rte_kvargs.c | 17 ++-- 38 files changed, 266 insertions(+), 206 deletions(-)