DPDK  18.11.11
Data Structures | Macros | Functions
rte_ether.h File Reference
#include <stdint.h>
#include <stdio.h>
#include <rte_memcpy.h>
#include <rte_random.h>
#include <rte_mbuf.h>
#include <rte_byteorder.h>

Go to the source code of this file.

Data Structures

struct  ether_addr
 
struct  ether_hdr
 
struct  vlan_hdr
 
struct  vxlan_hdr
 
struct  vxlan_gpe_hdr
 

Macros

#define ETHER_ADDR_LEN   6
 
#define ETHER_TYPE_LEN   2
 
#define ETHER_CRC_LEN   4
 
#define ETHER_HDR_LEN   (ETHER_ADDR_LEN * 2 + ETHER_TYPE_LEN)
 
#define ETHER_MIN_LEN   64
 
#define ETHER_MAX_LEN   1518
 
#define ETHER_MTU   (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
 
#define ETHER_MAX_VLAN_FRAME_LEN   (ETHER_MAX_LEN + 4)
 
#define ETHER_MAX_JUMBO_FRAME_LEN   0x3F00
 
#define ETHER_MAX_VLAN_ID   4095
 
#define ETHER_MIN_MTU   68
 
#define ETHER_LOCAL_ADMIN_ADDR   0x02
 
#define ETHER_GROUP_ADDR   0x01
 
#define ETHER_TYPE_IPv4   0x0800
 
#define ETHER_TYPE_IPv6   0x86DD
 
#define ETHER_TYPE_ARP   0x0806
 
#define ETHER_TYPE_RARP   0x8035
 
#define ETHER_TYPE_VLAN   0x8100
 
#define ETHER_TYPE_QINQ   0x88A8
 
#define ETHER_TYPE_ETAG   0x893F
 
#define ETHER_TYPE_1588   0x88F7
 
#define ETHER_TYPE_SLOW   0x8809
 
#define ETHER_TYPE_TEB   0x6558
 
#define ETHER_TYPE_LLDP   0x88CC
 
#define ETHER_TYPE_MPLS   0x8847
 
#define ETHER_TYPE_MPLSM   0x8848
 
#define ETHER_VXLAN_HLEN   (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr))
 
#define VXLAN_GPE_TYPE_IPV4   1
 
#define VXLAN_GPE_TYPE_IPV6   2
 
#define VXLAN_GPE_TYPE_ETH   3
 
#define VXLAN_GPE_TYPE_NSH   4
 
#define VXLAN_GPE_TYPE_MPLS   5
 
#define VXLAN_GPE_TYPE_GBP   6
 
#define VXLAN_GPE_TYPE_VBNG   7
 
#define ETHER_VXLAN_GPE_HLEN
 

Functions

static int is_same_ether_addr (const struct ether_addr *ea1, const struct ether_addr *ea2)
 
static int is_zero_ether_addr (const struct ether_addr *ea)
 
static int is_unicast_ether_addr (const struct ether_addr *ea)
 
static int is_multicast_ether_addr (const struct ether_addr *ea)
 
static int is_broadcast_ether_addr (const struct ether_addr *ea)
 
static int is_universal_ether_addr (const struct ether_addr *ea)
 
static int is_local_admin_ether_addr (const struct ether_addr *ea)
 
static int is_valid_assigned_ether_addr (const struct ether_addr *ea)
 
static void eth_random_addr (uint8_t *addr)
 
static void ether_addr_copy (const struct ether_addr *ea_from, struct ether_addr *ea_to)
 
static void ether_format_addr (char *buf, uint16_t size, const struct ether_addr *eth_addr)
 
static int rte_vlan_strip (struct rte_mbuf *m)
 
static int rte_vlan_insert (struct rte_mbuf **m)
 

Detailed Description

Ethernet Helpers in RTE

Definition in file rte_ether.h.

Macro Definition Documentation

#define ETHER_ADDR_LEN   6
#define ETHER_TYPE_LEN   2

Length of Ethernet type field.

Definition at line 27 of file rte_ether.h.

#define ETHER_CRC_LEN   4

Length of Ethernet CRC.

Definition at line 28 of file rte_ether.h.

#define ETHER_HDR_LEN   (ETHER_ADDR_LEN * 2 + ETHER_TYPE_LEN)

Length of Ethernet header.

Examples:
examples/ipsec-secgw/ipsec-secgw.c.

Definition at line 29 of file rte_ether.h.

#define ETHER_MIN_LEN   64

Minimum frame len, including CRC.

Definition at line 31 of file rte_ether.h.

#define ETHER_MAX_LEN   1518
#define ETHER_MTU   (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)

Ethernet MTU.

Definition at line 33 of file rte_ether.h.

#define ETHER_MAX_VLAN_FRAME_LEN   (ETHER_MAX_LEN + 4)

Maximum VLAN frame length, including CRC.

Definition at line 36 of file rte_ether.h.

#define ETHER_MAX_JUMBO_FRAME_LEN   0x3F00

Maximum Jumbo frame length, including CRC.

Examples:
examples/ethtool/ethtool-app/ethapp.c.

Definition at line 39 of file rte_ether.h.

#define ETHER_MAX_VLAN_ID   4095

Maximum VLAN ID.

Definition at line 42 of file rte_ether.h.

#define ETHER_MIN_MTU   68

Minimum MTU for IPv4 packets, see RFC 791.

Examples:
examples/ethtool/ethtool-app/ethapp.c.

Definition at line 44 of file rte_ether.h.

#define ETHER_LOCAL_ADMIN_ADDR   0x02

Locally assigned Eth. address.

Examples:
examples/l3fwd/main.c, and examples/performance-thread/l3fwd-thread/main.c.

Definition at line 61 of file rte_ether.h.

#define ETHER_GROUP_ADDR   0x01

Multicast or broadcast Eth. address.

Definition at line 62 of file rte_ether.h.

#define ETHER_TYPE_IPv4   0x0800
#define ETHER_TYPE_IPv6   0x86DD
#define ETHER_TYPE_ARP   0x0806

Arp Protocol.

Examples:
examples/bond/main.c.

Definition at line 300 of file rte_ether.h.

#define ETHER_TYPE_RARP   0x8035

Reverse Arp Protocol.

Definition at line 301 of file rte_ether.h.

#define ETHER_TYPE_VLAN   0x8100

IEEE 802.1Q VLAN tagging.

Examples:
examples/bond/main.c, examples/tep_termination/vxlan.c, and examples/vhost/main.c.

Definition at line 302 of file rte_ether.h.

#define ETHER_TYPE_QINQ   0x88A8

IEEE 802.1ad QinQ tagging.

Definition at line 303 of file rte_ether.h.

#define ETHER_TYPE_ETAG   0x893F

IEEE 802.1BR E-Tag.

Definition at line 304 of file rte_ether.h.

#define ETHER_TYPE_1588   0x88F7

IEEE 802.1AS 1588 Precise Time Protocol.

Definition at line 305 of file rte_ether.h.

#define ETHER_TYPE_SLOW   0x8809

Slow protocols (LACP and Marker).

Definition at line 306 of file rte_ether.h.

#define ETHER_TYPE_TEB   0x6558

Transparent Ethernet Bridging.

Definition at line 307 of file rte_ether.h.

#define ETHER_TYPE_LLDP   0x88CC

LLDP Protocol.

Definition at line 308 of file rte_ether.h.

#define ETHER_TYPE_MPLS   0x8847

MPLS ethertype.

Definition at line 309 of file rte_ether.h.

#define ETHER_TYPE_MPLSM   0x8848

MPLS multicast ethertype.

Definition at line 310 of file rte_ether.h.

#define ETHER_VXLAN_HLEN   (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr))

VXLAN tunnel header length.

Examples:
examples/tep_termination/vxlan.c.

Definition at line 312 of file rte_ether.h.

#define VXLAN_GPE_TYPE_IPV4   1

IPv4 Protocol.

Definition at line 328 of file rte_ether.h.

#define VXLAN_GPE_TYPE_IPV6   2

IPv6 Protocol.

Definition at line 329 of file rte_ether.h.

#define VXLAN_GPE_TYPE_ETH   3

Ethernet Protocol.

Definition at line 330 of file rte_ether.h.

#define VXLAN_GPE_TYPE_NSH   4

NSH Protocol.

Definition at line 331 of file rte_ether.h.

#define VXLAN_GPE_TYPE_MPLS   5

MPLS Protocol.

Definition at line 332 of file rte_ether.h.

#define VXLAN_GPE_TYPE_GBP   6

GBP Protocol.

Definition at line 333 of file rte_ether.h.

#define VXLAN_GPE_TYPE_VBNG   7

vBNG Protocol.

Definition at line 334 of file rte_ether.h.

#define ETHER_VXLAN_GPE_HLEN
Value:
(sizeof(struct udp_hdr) + \
sizeof(struct vxlan_gpe_hdr))

VXLAN-GPE tunnel header length.

Definition at line 336 of file rte_ether.h.

Function Documentation

static int is_same_ether_addr ( const struct ether_addr ea1,
const struct ether_addr ea2 
)
inlinestatic

Check if two Ethernet addresses are the same.

Parameters
ea1A pointer to the first ether_addr structure containing the ethernet address.
ea2A pointer to the second ether_addr structure containing the ethernet address.
Returns
True (1) if the given two ethernet address are the same; False (0) otherwise.
Examples:
examples/tep_termination/vxlan_setup.c, and examples/vhost/main.c.

Definition at line 78 of file rte_ether.h.

static int is_zero_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is filled with zeros.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is filled with zeros; false (0) otherwise.

Definition at line 98 of file rte_ether.h.

static int is_unicast_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is a unicast address.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a unicast address; false (0) otherwise.

Definition at line 117 of file rte_ether.h.

static int is_multicast_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is a multicast address.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a multicast address; false (0) otherwise.

Definition at line 132 of file rte_ether.h.

static int is_broadcast_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is a broadcast address.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a broadcast address; false (0) otherwise.
Examples:
examples/vhost/main.c.

Definition at line 147 of file rte_ether.h.

static int is_universal_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is a universally assigned address.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a universally assigned address; false (0) otherwise.

Definition at line 165 of file rte_ether.h.

static int is_local_admin_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is a locally assigned address.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a locally assigned address; false (0) otherwise.

Definition at line 180 of file rte_ether.h.

static int is_valid_assigned_ether_addr ( const struct ether_addr ea)
inlinestatic

Check if an Ethernet address is a valid address. Checks that the address is a unicast address and is not filled with zeros.

Parameters
eaA pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is valid; false (0) otherwise.
Examples:
examples/ethtool/lib/rte_ethtool.c.

Definition at line 196 of file rte_ether.h.

static void eth_random_addr ( uint8_t *  addr)
inlinestatic

Generate a random Ethernet address that is locally administered and not multicast.

Parameters
addrA pointer to Ethernet address.

Definition at line 207 of file rte_ether.h.

static void ether_addr_copy ( const struct ether_addr ea_from,
struct ether_addr ea_to 
)
inlinestatic
static void ether_format_addr ( char *  buf,
uint16_t  size,
const struct ether_addr eth_addr 
)
inlinestatic
static int rte_vlan_strip ( struct rte_mbuf m)
inlinestatic

Extract VLAN tag information into mbuf

Software version of VLAN stripping

Parameters
mThe packet mbuf.
Returns
  • 0: Success
  • 1: not a vlan packet

Definition at line 351 of file rte_ether.h.

static int rte_vlan_insert ( struct rte_mbuf **  m)
inlinestatic

Insert VLAN tag into mbuf.

Software version of VLAN unstripping

Parameters
mThe packet mbuf.
Returns
  • 0: On success -EPERM: mbuf is is shared overwriting would be unsafe -ENOSPC: not enough headroom in mbuf

Definition at line 383 of file rte_ether.h.