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 CB7A1A00C2; Sat, 13 Mar 2021 23:22:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0CB2160906; Sat, 13 Mar 2021 23:22:32 +0100 (CET) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by mails.dpdk.org (Postfix) with ESMTP id 583BC16088A for ; Sat, 13 Mar 2021 23:22:28 +0100 (CET) Received: by mail-lf1-f43.google.com with SMTP id v9so51144234lfa.1 for ; Sat, 13 Mar 2021 14:22:28 -0800 (PST) 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=EwvmS2wl6zo24TEUVyaG6PhN7Wu1VnCoqPPMwb9bUXo=; b=u2Z6+l8vTzjZs6YG1ey/NePbvhLzFndmtAZgOiENwOo2GXmfgIdNpkYasrY6BKrFc9 GtKVU7B00JvsAFgzcDqjy9uRQFvR8YIa7lOXSmBtaf9DA8HAWWofOru+MxD3SMaIKV+4 4yJDT9DH5fdE8xV+HqHl7Dy3/IE9qnnlZQo2aN0U+MpC/waX0pelSuYSjePtdrWVRSGY 5JhRT8WFkcB03dEtxDyfeq8zCNsVXE3IettEuxaNEA+aj3dP5ITxmEnJ1jnCj2slRk71 uaZ8U1AsBAWz35UDH/qpWcGHGiv4uWpczIigPWTrKVdkoW29R3Y+CFj8KAf7Pr1Pd9Ku D41Q== 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=EwvmS2wl6zo24TEUVyaG6PhN7Wu1VnCoqPPMwb9bUXo=; b=ScVV2pc7IqYcnvSZD4wBjdJadOmrl+cHO+XXmBLAwIT4N7NAZok5SL4mazeIXR7FRQ baKTqaVTQ95FLsyNxpo1zwMtNazN9DDPDPMO7rELL9Zn6ObZ7J0Oqh58BteNSMTIrMbB JOoq62EtC7vcZIgYpW+1fCg+nnTDagwDLdrR2L09MRNSzY+CNZxda2B9NotemdTm9JZS VxXshnSTwGBFnjfh/7+Ap8jVXA9V4J9pxfWpmmJwAvZbSz8qFvnBGpTy4QPUWULEziWS jALnGmNN8MlVxY4sczc9LPGLC3AKGW2xEY2EmmgQ9rsSDVpnVR3FHePI/4Ju6DL2+4lC HCuA== X-Gm-Message-State: AOAM531JEroZrLt5Od+RB6GFQ8k/VNI4qSlOz2BVvKszQJZ/sAxPfV3A OZHdm0XsfstylWZ1tlEJPfGc9shOqkCDw6B9 X-Google-Smtp-Source: ABdhPJx4X/23gAqGI9Bfzv8CLwVgj+IqF/KPVVhfneB37o1W/wSrS8+TYZyCVdIoBUcmXGLdtar0QQ== X-Received: by 2002:a05:6512:39d6:: with SMTP id k22mr3650882lfu.378.1615674147718; Sat, 13 Mar 2021 14:22:27 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id t200sm2176685lff.280.2021.03.13.14.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 14:22:27 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Pallavi Kadam , Dmitry Malloy , Narcisa Ana Maria Vasile , Tyler Retzlaff , Dmitry Kozlyuk , Olivier Matz Date: Sun, 14 Mar 2021 01:22:16 +0300 Message-Id: <20210313222217.18271-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210313222217.18271-1-dmitry.kozliuk@gmail.com> References: <20210313025645.6034-1-dmitry.kozliuk@gmail.com> <20210313222217.18271-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 4/4] 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 --- 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 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/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..87fbc26431 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -17,12 +17,27 @@ #include +#ifndef RTE_EXEC_ENV_WINDOWS + #include #include #include #include #include +#else + +#include + +#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 #include -- 2.29.2