* [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17
@ 2018-07-31 9:55 Bin Meng
2018-07-31 9:55 ` [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication Bin Meng
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Bin Meng @ 2018-07-31 9:55 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
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
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
new file mode 100644
index 0000000..9144ad7
--- /dev/null
+++ b/include/linux/if_ether.h
@@ -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, <waltje@uWalt.NL.Mugnet.ORG>
+ * Donald Becker, <becker@super.org>
+ * Alan Cox, <alan@lxorguk.ukuu.org.uk>
+ * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
+ *
+ * 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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication
2018-07-31 9:55 [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Bin Meng
@ 2018-07-31 9:55 ` Bin Meng
2018-08-02 16:48 ` Joe Hershberger
2018-10-11 19:24 ` [U-Boot] " Joe Hershberger
2018-07-31 9:55 ` [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros Bin Meng
` (2 subsequent siblings)
3 siblings, 2 replies; 9+ messages in thread
From: Bin Meng @ 2018-07-31 9:55 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
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(-)
diff --git a/board/Synology/ds414/cmd_syno.c b/board/Synology/ds414/cmd_syno.c
index 34643ff..59e6fe0 100644
--- a/board/Synology/ds414/cmd_syno.c
+++ b/board/Synology/ds414/cmd_syno.c
@@ -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="
diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c
index 8d7c271..e3c403c 100644
--- a/drivers/net/dc2114x.c
+++ b/drivers/net/dc2114x.c
@@ -123,7 +123,6 @@
#define TOUT_LOOP 1000000
#define SETUP_FRAME_LEN 192
-#define ETH_ALEN 6
struct de4x5_desc {
volatile s32 status;
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index ae65b64..2fe0ba6 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -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 */
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 5c1f5fc..f34245b 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -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)
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 0ed9bb5..86f6898 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -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
diff --git a/drivers/net/ns8382x.c b/drivers/net/ns8382x.c
index f941c15..ea7ece5 100644
--- a/drivers/net/ns8382x.c
+++ b/drivers/net/ns8382x.c
@@ -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
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index ea52343..590f8ce 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -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. */
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index e0e3a6d..a78f3d2 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -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, \
diff --git a/drivers/usb/eth/lan7x.h b/drivers/usb/eth/lan7x.h
index d1b1047..7af610b 100644
--- a/drivers/usb/eth/lan7x.h
+++ b/drivers/usb/eth/lan7x.h
@@ -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
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 8ab9b9f..90ef1f0 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -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++;
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d47e29e..eec639f 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -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).
diff --git a/include/net.h b/include/net.h
index 62f82c4..3cb111f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -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 */
diff --git a/include/usb_ether.h b/include/usb_ether.h
index 49f47d3..e85acad 100644
--- a/include/usb_ether.h
+++ b/include/usb_ether.h
@@ -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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros
2018-07-31 9:55 [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Bin Meng
2018-07-31 9:55 ` [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication Bin Meng
@ 2018-07-31 9:55 ` Bin Meng
2018-08-02 16:49 ` Joe Hershberger
2018-10-11 19:25 ` [U-Boot] " Joe Hershberger
2018-08-02 16:47 ` [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Joe Hershberger
2018-10-11 19:24 ` [U-Boot] " Joe Hershberger
3 siblings, 2 replies; 9+ messages in thread
From: Bin Meng @ 2018-07-31 9:55 UTC (permalink / raw)
To: u-boot
There 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.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
include/linux/if_ether.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 9144ad7..0d62aef 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17
2018-07-31 9:55 [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Bin Meng
2018-07-31 9:55 ` [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication Bin Meng
2018-07-31 9:55 ` [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros Bin Meng
@ 2018-08-02 16:47 ` Joe Hershberger
2018-10-11 19:24 ` [U-Boot] " Joe Hershberger
3 siblings, 0 replies; 9+ messages in thread
From: Joe Hershberger @ 2018-08-02 16:47 UTC (permalink / raw)
To: u-boot
On Tue, Jul 31, 2018 at 4:55 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> 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.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication
2018-07-31 9:55 ` [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication Bin Meng
@ 2018-08-02 16:48 ` Joe Hershberger
2018-10-11 19:24 ` [U-Boot] " Joe Hershberger
1 sibling, 0 replies; 9+ messages in thread
From: Joe Hershberger @ 2018-08-02 16:48 UTC (permalink / raw)
To: u-boot
On Tue, Jul 31, 2018 at 4:55 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> 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.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros
2018-07-31 9:55 ` [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros Bin Meng
@ 2018-08-02 16:49 ` Joe Hershberger
2018-10-11 19:25 ` [U-Boot] " Joe Hershberger
1 sibling, 0 replies; 9+ messages in thread
From: Joe Hershberger @ 2018-08-02 16:49 UTC (permalink / raw)
To: u-boot
On Tue, Jul 31, 2018 at 4:55 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> There 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.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] linux/if_ether.h: Initial import from Linux kernel v4.17
2018-07-31 9:55 [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Bin Meng
` (2 preceding siblings ...)
2018-08-02 16:47 ` [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Joe Hershberger
@ 2018-10-11 19:24 ` Joe Hershberger
3 siblings, 0 replies; 9+ messages in thread
From: Joe Hershberger @ 2018-10-11 19:24 UTC (permalink / raw)
To: u-boot
Hi Bin,
https://patchwork.ozlabs.org/patch/951499/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] net.h: Include linux/if_ether.h to avoid duplication
2018-07-31 9:55 ` [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication Bin Meng
2018-08-02 16:48 ` Joe Hershberger
@ 2018-10-11 19:24 ` Joe Hershberger
1 sibling, 0 replies; 9+ messages in thread
From: Joe Hershberger @ 2018-10-11 19:24 UTC (permalink / raw)
To: u-boot
Hi Bin,
https://patchwork.ozlabs.org/patch/951500/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] linux/if_ether.h: Add VLAN related macros
2018-07-31 9:55 ` [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros Bin Meng
2018-08-02 16:49 ` Joe Hershberger
@ 2018-10-11 19:25 ` Joe Hershberger
1 sibling, 0 replies; 9+ messages in thread
From: Joe Hershberger @ 2018-10-11 19:25 UTC (permalink / raw)
To: u-boot
Hi Bin,
https://patchwork.ozlabs.org/patch/951501/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-10-11 19:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 9:55 [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Bin Meng
2018-07-31 9:55 ` [U-Boot] [PATCH v2 2/3] net.h: Include linux/if_ether.h to avoid duplication Bin Meng
2018-08-02 16:48 ` Joe Hershberger
2018-10-11 19:24 ` [U-Boot] " Joe Hershberger
2018-07-31 9:55 ` [U-Boot] [PATCH v2 3/3] linux/if_ether.h: Add VLAN related macros Bin Meng
2018-08-02 16:49 ` Joe Hershberger
2018-10-11 19:25 ` [U-Boot] " Joe Hershberger
2018-08-02 16:47 ` [U-Boot] [PATCH v2 1/3] linux/if_ether.h: Initial import from Linux kernel v4.17 Joe Hershberger
2018-10-11 19:24 ` [U-Boot] " Joe Hershberger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.