linux/if_ether.h: Initial import from Linux kernel v4.17
Subsystems (2)
PATCH v2 1/3 linux/if_ether.h: Initial import from Linux kernel v4.17
This imports include/uapi/linux/if_ether.h from Linux kernel v4.17. It can be very helpful When porting Linux ethernet driver to U-Boot.
Note it is not exactly the same as the kernel one, as checkpatch issues are fixed.
---
Changes in v2:
- correct one indention to use space
include/linux/if_ether.h | 159 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 include/linux/if_ether.h
include/linux/if_ether.h new file +159 -0
@@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* +* INET An implementation of the TCP/IP protocol suite for the LINUX +* operating system. INET is implemented using the BSD Socket +* interface as the means of communication with the user level. +* +* Global definitions for the Ethernet IEEE 802.3 interface. +* +* Version: @(#)if_ether.h 1.0.1a 02/08/94 +* +* Author: Fred N. van Kempen, <[email protected]> +* Donald Becker, <[email protected]> +* Alan Cox, <[email protected]> +* Steve Whitehouse, <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _UAPI_LINUX_IF_ETHER_H +#define _UAPI_LINUX_IF_ETHER_H + +#include <linux/types.h> + +/* +* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble +* and FCS/CRC (frame check sequence). +*/ + +#define ETH_ALEN 6/* Octets in one ethernet addr */ +#define ETH_TLEN 2/* Octets in ethernet type field */ +#define ETH_HLEN 14/* Total octets in header. */ +#define ETH_ZLEN 60/* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500/* Max. octets in payload */ +#define ETH_FRAME_LEN 1514/* Max. octets in frame sans FCS */ +#define ETH_FCS_LEN 4/* Octets in the FCS */ + +#define ETH_MIN_MTU 68/* Min IPv4 MTU per RFC791 */ +#define ETH_MAX_MTU 0xFFFFU/* 65535, same as IP_MAX_MTU */ + +/* +* These are the defined Ethernet Protocol ID's. +*/ + +#define ETH_P_LOOP 0x0060/* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200/* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201/* Xerox PUP Addr Trans packet */ +#define ETH_P_TSN 0x22F0/* TSN (IEEE 1722) packet */ +#define ETH_P_ERSPAN2 0x22EB/* ERSPAN version 2 (type III) */ +#define ETH_P_IP 0x0800/* Internet Protocol packet */ +#define ETH_P_X25 0x0805/* CCITT X.25 */ +#define ETH_P_ARP 0x0806/* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF/* G8BPQ AX.25 Ethernet Packet */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IEEEPUP 0x0a00/* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01/* Xerox IEEE802.3 PUP Addr Trans packet */ +#define ETH_P_BATMAN 0x4305/* B.A.T.M.A.N.-Advanced packet */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_DEC 0x6000/* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001/* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002/* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003/* DEC DNA Routing */ +#define ETH_P_LAT 0x6004/* DEC LAT */ +#define ETH_P_DIAG 0x6005/* DEC Diagnostics */ +#define ETH_P_CUST 0x6006/* DEC Customer use */ +#define ETH_P_SCA 0x6007/* DEC Systems Comms Arch */ +#define ETH_P_TEB 0x6558/* Trans Ether Bridging */ +#define ETH_P_RARP 0x8035/* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B/* Appletalk DDP */ +#define ETH_P_AARP 0x80F3/* Appletalk AARP */ +#define ETH_P_8021Q 0x8100/* 802.1Q VLAN Extended Header */ +#define ETH_P_ERSPAN 0x88BE/* ERSPAN type II */ +#define ETH_P_IPX 0x8137/* IPX over DIX */ +#define ETH_P_IPV6 0x86DD/* IPv6 over bluebook */ +#define ETH_P_PAUSE 0x8808/* IEEE Pause frames. See 802.3 31B */ +#define ETH_P_SLOW 0x8809/* Slow Protocol. See 802.3ad 43B */ +#define ETH_P_WCCP 0x883E/* Web-cache coordination */ +/* protocol defined in */ +/* draft-wilson-wrec-wccp-v2-00.txt */ +#define ETH_P_MPLS_UC 0x8847/* MPLS Unicast traffic */ +#define ETH_P_MPLS_MC 0x8848/* MPLS Multicast traffic */ +#define ETH_P_ATMMPOA 0x884c/* MultiProtocol Over ATM */ +#define ETH_P_PPP_DISC 0x8863/* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864/* PPPoE session messages */ +#define ETH_P_LINK_CTL 0x886c/* HPNA, wlan link local tunnel */ +#define ETH_P_ATMFATE 0x8884/* Frame-based ATM Transport over Ethernet */ +#define ETH_P_PAE 0x888E/* Port Access Entity (IEEE 802.1X) */ +#define ETH_P_AOE 0x88A2/* ATA over Ethernet */ +#define ETH_P_8021AD 0x88A8/* 802.1ad Service VLAN */ +#define ETH_P_802_EX1 0x88B5/* 802.1 Local Experimental 1. */ +#define ETH_P_PREAUTH 0x88C7/* 802.11 Preauthentication */ +#define ETH_P_TIPC 0x88CA/* TIPC */ +#define ETH_P_MACSEC 0x88E5/* 802.1ae MACsec */ +#define ETH_P_8021AH 0x88E7/* 802.1ah Backbone Service Tag */ +#define ETH_P_MVRP 0x88F5/* 802.1Q MVRP */ +#define ETH_P_1588 0x88F7/* IEEE 1588 Timesync */ +#define ETH_P_NCSI 0x88F8/* NCSI protocol */ +#define ETH_P_PRP 0x88FB/* IEC 62439-3 PRP/HSRv0 */ +#define ETH_P_FCOE 0x8906/* Fibre Channel over Ethernet */ +#define ETH_P_IBOE 0x8915/* Infiniband over Ethernet */ +#define ETH_P_TDLS 0x890D/* TDLS */ +#define ETH_P_FIP 0x8914/* FCoE Initialization Protocol */ +#define ETH_P_80221 0x8917/* IEEE 802.21 Media Independent */ +/* Handover Protocol */ +#define ETH_P_HSR 0x892F/* IEC 62439-3 HSRv1 */ +#define ETH_P_NSH 0x894F/* Network Service Header */ +#define ETH_P_LOOPBACK 0x9000/* Ethernet loopback packet, per IEEE 802.3 */ +#define ETH_P_QINQ1 0x9100/* deprecated QinQ VLAN */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_QINQ2 0x9200/* deprecated QinQ VLAN */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_QINQ3 0x9300/* deprecated QinQ VLAN] */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_EDSA 0xDADA/* Ethertype DSA */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IFE 0xED3E/* ForCES inter-FE LFB type */ +#define ETH_P_AF_IUCV 0xFBFB/* IBM af_iucv */ +/* [ NOT AN OFFICIALLY REGISTERED ID ] */ + +#define ETH_P_802_3_MIN 0x0600/* If the value in the ethernet type is less */ +/* than this value then the frame is Ethernet */ +/* II. Else it is 802.3 */ + +/* +* Non DIX types. Won't clash for 1500 types. +*/ + +#define ETH_P_802_3 0x0001/* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002/* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003/* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004/* 802.2 frames */ +#define ETH_P_SNAP 0x0005/* Internal only */ +#define ETH_P_DDCMP 0x0006/* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007/* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008/* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009/* Localtalk pseudo type */ +#define ETH_P_CAN 0x000C/* CAN: Controller Area Network */ +#define ETH_P_CANFD 0x000D/* CANFD: CAN flexible data rate*/ +#define ETH_P_PPPTALK 0x0010/* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011/* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015/* Mobitex (kaz at cafe.net) */ +#define ETH_P_CONTROL 0x0016/* Card specific control frames */ +#define ETH_P_IRDA 0x0017/* Linux-IrDA */ +#define ETH_P_ECONET 0x0018/* Acorn Econet */ +#define ETH_P_HDLC 0x0019/* HDLC frames */ +#define ETH_P_ARCNET 0x001A/* 1A for ArcNet :-) */ +#define ETH_P_DSA 0x001B/* Distributed Switch Arch */ +#define ETH_P_TRAILER 0x001C/* Trailer switch tagging */ +#define ETH_P_PHONET 0x00F5/* Nokia Phonet frames */ +#define ETH_P_IEEE802154 0x00F6/* IEEE802.15.4 frame */ +#define ETH_P_CAIF 0x00F7/* ST-Ericsson CAIF protocol */ +#define ETH_P_XDSA 0x00F8/* Multiplexed DSA protocol */ +#define ETH_P_MAP 0x00F9/* Qualcomm multiplexing and */ +/* aggregation protocol */ + + +#endif /* _UAPI_LINUX_IF_ETHER_H */
Signature · 1 line
2.7.4
PATCH v2 2/3 net.h: Include linux/if_ether.h to avoid duplication
There are plenty of existing drivers that have macros like ETH_ALEN defined in their own source files. Now that we imported the kernel's if_ether.h to U-Boot we can reduce some duplication.
---
Changes in v2: None
board/Synology/ds414/cmd_syno.c | 1 - drivers/net/dc2114x.c | 1 - drivers/net/eepro100.c | 2 -- drivers/net/mvpp2.c | 3 --- drivers/net/natsemi.c | 1 - drivers/net/ns8382x.c | 1 - drivers/net/rtl8139.c | 4 ---- drivers/net/rtl8169.c | 4 ---- drivers/usb/eth/lan7x.h | 2 +- drivers/usb/gadget/ether.c | 9 ++------- drivers/usb/gadget/rndis.c | 6 ------ include/net.h | 1 + include/usb_ether.h | 10 ---------- 13 files changed, 4 insertions(+), 41 deletions(-)
board/Synology/ds414/cmd_syno.c +0 -1
@@ -14,7 +14,6 @@#include <asm/io.h> #include "../drivers/ddr/marvell/axp/ddr3_init.h" -#define ETH_ALEN 6#define ETHADDR_MAX 4#define SYNO_SN_TAG "SN="#define SYNO_CHKSUM_TAG "CHK="
drivers/net/dc2114x.c +0 -1
@@ -123,7 +123,6 @@#define TOUT_LOOP 1000000#define SETUP_FRAME_LEN 192 -#define ETH_ALEN 6struct de4x5_desc {volatile s32 status;
drivers/net/eepro100.c +0 -2
@@ -193,8 +193,6 @@ struct descriptor { /* A generic descriptor. */#define TOUT_LOOP 1000000 -#define ETH_ALEN 6 -static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ static int rx_next;/* RX descriptor ring pointer */
drivers/net/mvpp2.c +0 -3
@@ -35,8 +35,6 @@DECLARE_GLOBAL_DATA_PTR ; -#define ETH_ALEN 6/* Octets in one ethernet addr */ -#define __verify_pcpu_ptr (ptr) \ do { \ const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
@@ -58,7 +56,6 @@ do { \#define NET_SKB_PAD max(32, MVPP2_CPU_D_CACHE_LINE_SIZE)#define CONFIG_NR_CPUS 1 -#define ETH_HLEN ETHER_HDR_SIZE/* Total octets in header */ /* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */ #define WRAP (2 + ETH_HLEN + 4 + 32)
drivers/net/natsemi.c +0 -1
@@ -61,7 +61,6 @@#define EEPROM_SIZE 0xb/*12 16-bit chunks, or 24 bytes*/ #define DSIZE 0x00000FFF -#define ETH_ALEN 6#define CRC_SIZE 4#define TOUT_LOOP 500000#define TX_BUF_SIZE 1536
drivers/net/ns8382x.c +0 -1
@@ -59,7 +59,6 @@/* defines */ #define DSIZE 0x00000FFF -#define ETH_ALEN 6#define CRC_SIZE 4#define TOUT_LOOP 500000#define TX_BUF_SIZE 1536
drivers/net/rtl8139.c +0 -4
@@ -80,10 +80,6 @@#define RTL_TIMEOUT 100000 -#define ETH_FRAME_LEN 1514 -#define ETH_ALEN 6 -#define ETH_ZLEN 60 -/* PCI Tuning Parameters Threshold is bytes transferred to chip before transmission starts. */ #define TX_FIFO_THRESH 256/* In bytes, rounded down to 32 byte units. */
drivers/net/rtl8169.c +0 -4
@@ -102,10 +102,6 @@ static int media[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };#define RTL_R16 (reg) readw(ioaddr + (reg))#define RTL_R32 (reg) readl(ioaddr + (reg)) -#define ETH_FRAME_LEN MAX_ETH_FRAME_SIZE -#define ETH_ALEN MAC_ADDR_LEN -#define ETH_ZLEN 60 -#define bus_to_phys (a) pci_mem_to_phys((pci_dev_t)(unsigned long)dev->priv, \ (pci_addr_t)(unsigned long)a)#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)(unsigned long)dev->priv, \
drivers/usb/eth/lan7x.h +1 -1
@@ -94,7 +94,7 @@#define LAN7X_MAC_RX_MAX_SIZE (mtu) \ ((mtu) << 16)/* Max frame size */ #define LAN7X_MAC_RX_MAX_SIZE_DEFAULT \ - LAN7X_MAC_RX_MAX_SIZE(ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* CRC */) + LAN7X_MAC_RX_MAX_SIZE(PKTSIZE_ALIGN + 4 /* VLAN */ + 4 /* CRC */)/* Timeouts */ #define USB_CTRL_SET_TIMEOUT_MS 5000
drivers/usb/gadget/ether.c +2 -7
@@ -71,11 +71,6 @@ unsigned packet_received, packet_sent;* RNDIS specs are ambiguous and appear to be incomplete, and are also * needlessly complex. They borrow more from CDC ACM than CDC ECM. */ -#define ETH_ALEN 6/* Octets in one ethernet addr */ -#define ETH_HLEN 14/* Total octets in header. */ -#define ETH_ZLEN 60/* Min. octets in frame sans FCS */ -#define ETH_DATA_LEN 1500/* Max. octets in payload */ -#define ETH_FRAME_LEN PKTSIZE_ALIGN/* Max. octets in frame sans FCS */ #define DRIVER_DESC "Ethernet Gadget"/* Based on linux 2.6.27 version */
@@ -529,7 +524,7 @@ static const struct usb_cdc_ether_desc ether_desc = {/* this descriptor actually adds value, surprise! */ .iMACAddress = STRING_ETHADDR, .bmEthernetStatistics = __constant_cpu_to_le32(0), /* no statistics */ - .wMaxSegmentSize = __constant_cpu_to_le16(ETH_FRAME_LEN), + .wMaxSegmentSize = __constant_cpu_to_le16(PKTSIZE_ALIGN), .wNumberMCFilters = __constant_cpu_to_le16(0), .bNumberPowerFilters = 0, };
@@ -1575,7 +1570,7 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req) req->length -= length; req->actual -= length; } -if (req->actual <ETH_HLEN ||ETH_FRAME_LEN < req->actual) { +if (req->actual <ETH_HLEN ||PKTSIZE_ALIGN < req->actual) { length_err: dev->stats.rx_errors++; dev->stats.rx_length_errors++;
drivers/usb/gadget/rndis.c +0 -6
@@ -35,12 +35,6 @@#include "rndis.h" -#define ETH_ALEN 6/* Octets in one ethernet addr */ -#define ETH_HLEN 14/* Total octets in header. */ -#define ETH_ZLEN 60/* Min. octets in frame sans FCS */ -#define ETH_DATA_LEN 1500/* Max. octets in payload */ -#define ETH_FRAME_LEN PKTSIZE_ALIGN/* Max. octets in frame sans FCS */ -/* * The driver for your USB chip needs to support ep0 OUT to work with * RNDIS, plus all three CDC Ethernet endpoints (interrupt not optional).
include/net.h +1 -0
@@ -14,6 +14,7 @@#include <asm/cache.h> #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ +#include <linux/if_ether.h> #define DEBUG_LL_STATE 0/* Link local state machine changes */ #define DEBUG_DEV_PKT 0/* Packets or info directed to the device */
include/usb_ether.h +0 -10
@@ -8,16 +8,6 @@#include <net.h> -/* -* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble -* and FCS/CRC (frame check sequence). -*/ -#define ETH_ALEN 6/* Octets in one ethernet addr */ -#define ETH_HLEN 14/* Total octets in header. */ -#define ETH_ZLEN 60/* Min. octets in frame sans FCS */ -#define ETH_DATA_LEN 1500/* Max. octets in payload */ -#define ETH_FRAME_LEN PKTSIZE_ALIGN/* Max. octets in frame sans FCS */ -/* TODO(sjg at chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */ struct ueth_data {/* eth info */
Signature · 1 line
2.7.4
PATCH v2 2/3 net.h: Include linux/if_ether.h to avoid duplication
Quoted 5 lines · Bin Meng
There are plenty of existing drivers that have macros like
ETH_ALENdefined in their own source files. Now that we imported the kernel'sif_ether.hto U-Boot we can reduce some duplication.Signed-off-by Bin Meng <[email protected]>
[U-Boot] net.h: Include linux/if_ether.h to avoid duplication
In reply to Bin MengHi Bin,
https://patchwork.ozlabs.org/patch/951500/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v2 3/3 linux/if_ether.h: Add VLAN related macros
In reply to Bin MengThere are VLAN related macros defined in include/linux/if_vlan.h in Linux kernel, as well as some kernel useful structures and inline functions. Instead of a complete import from kernel, let's add these VLAN macros to U-Boot's include/linux/if_ether.h.
---
Changes in v2: None
include/linux/if_ether.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/linux/if_ether.h +19 -0
@@ -155,5 +155,24 @@#define ETH_P_MAP 0x00F9/* Qualcomm multiplexing and */ /* aggregation protocol */ +/* The following macros come from Linux kernel include/linux/if_vlan.h */ + +#define VLAN_HLEN 4/* The additional bytes required by VLAN */ +/* (in addition to the Ethernet header) */ +#define VLAN_ETH_HLEN 18/* Total octets in header. */ +#define VLAN_ETH_ZLEN 64/* Min. octets in frame sans FCS */ + +/* +* According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan +*/ +#define VLAN_ETH_DATA_LEN 1500/* Max. octets in payload */ +#define VLAN_ETH_FRAME_LEN 1518/* Max. octets in frame sans FCS */ + +#define VLAN_PRIO_MASK 0xe000/* Priority Code Point */ +#define VLAN_PRIO_SHIFT 13 +#define VLAN_CFI_MASK 0x1000/* Canonical Format Indicator */ +#define VLAN_TAG_PRESENT VLAN_CFI_MASK +#define VLAN_VID_MASK 0x0fff/* VLAN Identifier */ +#define VLAN_N_VID 4096#endif /* _UAPI_LINUX_IF_ETHER_H */
Signature · 1 line
2.7.4
PATCH v2 3/3 linux/if_ether.h: Add VLAN related macros
Quoted 6 lines · Bin Meng
There are VLAN related macros defined in
include/linux/if_vlan.hin Linux kernel, as well as some kernel useful structures and inline functions. Instead of a complete import from kernel, let's add these VLAN macros to U-Boot'sinclude/linux/if_ether.h.Signed-off-by Bin Meng <[email protected]>
[U-Boot] linux/if_ether.h: Add VLAN related macros
In reply to Bin MengHi Bin,
https://patchwork.ozlabs.org/patch/951501/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v2 1/3 linux/if_ether.h: Initial import from Linux kernel v4.17
In reply to Bin MengQuoted 7 lines · Bin Meng
This imports
include/uapi/linux/if_ether.hfrom Linux kernel v4.17. It can be very helpful When porting Linux ethernet driver to U-Boot.Note it is not exactly the same as the kernel one, as checkpatch issues are fixed.
Signed-off-by Bin Meng <[email protected]>
Hi Bin,
https://patchwork.ozlabs.org/patch/951499/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe