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 76B6EA0524; Sat, 20 Mar 2021 12:28:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABDB01410A0; Sat, 20 Mar 2021 12:27:57 +0100 (CET) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by mails.dpdk.org (Postfix) with ESMTP id 2D3F7141086 for ; Sat, 20 Mar 2021 12:27:50 +0100 (CET) Received: by mail-lj1-f174.google.com with SMTP id f26so15055018ljp.8 for ; Sat, 20 Mar 2021 04:27:50 -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=x6Owd3DojeScZ9neWdFLqQnH8sRCzfxxV794/ffoWYE=; b=JcU8CZHFLbzw5IMsAJaWXEATjKXMZitp5qRMSI46+u4cIUotskwWQbHrVmXMf0GWmq +9jzP+GjGGXgTbMFzmt12PyorjhKwrL97cAQz4f7WYwH32Xs/8tKM2uAcxHamow7+lgq GnDjqxXYhuodL6vlD37mg82jVP+zD1R7YtzUBe0JkiSPdC8U4QUIMQcLPjlEQf/5/lZa +qOsQPDMCVym6tyyDXAhZH8t0Io5h7fKhDdrftSb1aKDU1gwC1vOvIBNqL1QYKHxnMCI RkKTqhehF2iCOgn0iYALwutM7aAr+9nYdrDPoAjAUYGH4ENo/ak5vPx2ZWF+suK7jUH4 CZNw== 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=x6Owd3DojeScZ9neWdFLqQnH8sRCzfxxV794/ffoWYE=; b=T76l3kXSPIZmOHaero6DlcdnFur455wwjLjVMSVyVyJqGEHNA4gherJqqnzR53IzDs QvF3oBCr3SKTQ9auQr1+6j6Mvmj7Ogd20RU7hpjgfp3ZnPp59fNNY3CnKIg66CP/xDJ/ uYYhHqEeknQfD6qqcvxcu74LHqVGgjOCyupKIJn6pCuzzFUaUH0MnkAiETQ8ZY8BUCmV dqbGZx7BfH/IKux23HEFsjQaKrl0aSW0izEuIesCjoV/zeEcOI7DXaqHusHy6a1Ibf90 nJBFLhJUyD77a3+/HBzTQs7krDfy6h5M4IjNVE4Cz7nRnnV7Z0iYEBdEFvvVTPzI1kAJ WXGQ== X-Gm-Message-State: AOAM531wFaykZgAgSgjpfpG9su0Y5mtSkCClLUWqhHovTSisubTnU3i5 s5Ey/cjA7B+DgqKPc9XsMWQRz6TYeq9D+Ps5 X-Google-Smtp-Source: ABdhPJwmxt0rx50BIgEDFRHXsa/2oSzjU5lbBhclbxempoVKpptvxrzP/ZoUxYFlhZJNSL+82fb9eQ== X-Received: by 2002:a2e:b4c7:: with SMTP id r7mr3434048ljm.462.1616239669481; Sat, 20 Mar 2021 04:27:49 -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 v26sm913976lfe.276.2021.03.20.04.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 04:27:49 -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 14:27:33 +0300 Message-Id: <20210320112733.13160-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210320112733.13160-1-dmitry.kozliuk@gmail.com> References: <20210306000500.8698-1-dmitry.kozliuk@gmail.com> <20210320112733.13160-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 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.2