From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit 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 -- 2.29.3