Helper Reference Manual 1.7.1
Loading...
Searching...
No Matches
eth.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2014-2018 Linaro Limited
3 */
4
11#ifndef ODPH_ETH_H_
12#define ODPH_ETH_H_
13
14#include <odp_api.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
27#define ODPH_ETHADDR_LEN 6
28#define ODPH_ETHHDR_LEN 14
29#define ODPH_VLANHDR_LEN 4
30#define ODPH_ETH_LEN_MIN 60
31#define ODPH_ETH_LEN_MIN_CRC 64
32#define ODPH_ETH_LEN_MAX 1514
33#define ODPH_ETH_LEN_MAX_CRC 1518
35/* The two byte odph_vlanhdr_t tci field is composed of the following three
36 * subfields - a three bit Priority Code Point (PCP), a one bit Drop
37 * Eligibility Indicator (DEI) and a twelve bit VLAN Identifier (VID). The
38 * following constants can be used to extract or modify these subfields, once
39 * the tci field has been read in and converted to host byte order. Note
40 * that the DEI subfield used to be the CFI bit.
41 */
42#define ODPH_VLANHDR_MAX_PRIO 7
43#define ODPH_VLANHDR_PCP_MASK 0xE000
44#define ODPH_VLANHDR_PCP_SHIFT 13
45#define ODPH_VLANHDR_DEI_MASK 0x1000
46#define ODPH_VLANHDR_DEI_SHIFT 12
47#define ODPH_VLANHDR_MAX_VID 0x0FFF
48#define ODPH_VLANHDR_VID_MASK 0x0FFF
49#define ODPH_VLANHDR_VID_SHIFT 0
57
61typedef struct ODP_PACKED {
64 odp_u16be_t type;
66
76typedef struct ODP_PACKED {
77 odp_u16be_t tci;
78 odp_u16be_t type;
80
82ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN,
83 "ODPH_ETHADDR_T__SIZE_ERROR");
84
85ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN,
86 "ODPH_ETHHDR_T__SIZE_ERROR");
87
88ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN,
89 "ODPH_VLANHDR_T__SIZE_ERROR");
92/* Ethernet header Ether Type ('type') values, a selected few */
93#define ODPH_ETHTYPE_IPV4 0x0800
94#define ODPH_ETHTYPE_ARP 0x0806
95#define ODPH_ETHTYPE_RARP 0x8035
96#define ODPH_ETHTYPE_VLAN 0x8100
97#define ODPH_ETHTYPE_VLAN_OUTER 0x88A8
98#define ODPH_ETHTYPE_IPV6 0x86dd
99#define ODPH_ETHTYPE_FLOW_CTRL 0x8808
100#define ODPH_ETHTYPE_MPLS 0x8847
101#define ODPH_ETHTYPE_MPLS_MCAST 0x8848
102#define ODPH_ETHTYPE_MACSEC 0x88E5
103#define ODPH_ETHTYPE_1588 0x88F7
122int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str);
123
128#ifdef __cplusplus
129}
130#endif
131
132#endif
struct ODP_PACKED odph_vlanhdr_t
IEEE 802.1Q VLAN header.
struct ODP_PACKED odph_ethaddr_t
Ethernet MAC address.
#define ODPH_ETHHDR_LEN
Ethernet header length.
Definition eth.h:28
struct ODP_PACKED odph_ethhdr_t
Ethernet header.
#define ODPH_VLANHDR_LEN
VLAN header length.
Definition eth.h:29
int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str)
Parse Ethernet from a string.
#define ODPH_ETHADDR_LEN
Ethernet address length.
Definition eth.h:27
Ethernet MAC address.
Definition eth.h:54
odp_u16be_t type
EtherType.
Definition eth.h:64
uint8_t addr[ODPH_ETHADDR_LEN]
Address.
Definition eth.h:55
odph_ethaddr_t dst
Destination address.
Definition eth.h:62
odp_u16be_t tci
Priority / CFI / VLAN ID.
Definition eth.h:77
odph_ethaddr_t src
Source address.
Definition eth.h:63