Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ethernet.h File Reference

Ethernet. More...

#include <zephyr/kernel.h>
#include <zephyr/types.h>
#include <stdbool.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/net/net_ip.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/lldp.h>
#include <zephyr/sys/util.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/ethernet_vlan.h>
#include <zephyr/net/ptp_time.h>
#include <zephyr/syscalls/ethernet.h>

Go to the source code of this file.

Data Structures

struct  net_eth_addr
 Ethernet address. More...
 
struct  ethernet_t1s_param
 Ethernet T1S specific parameters. More...
 
struct  ethernet_qav_param
 Ethernet Qav specific parameters. More...
 
struct  ethernet_qbv_param
 Ethernet Qbv specific parameters. More...
 
struct  ethernet_qbu_param
 Ethernet Qbu specific parameters. More...
 
struct  ethernet_filter
 Ethernet filter description. More...
 
struct  ethernet_txtime_param
 Ethernet TXTIME specific parameters. More...
 
struct  ethernet_api
 Ethernet L2 API operations. More...
 
struct  ethernet_lldp
 Ethernet LLDP specific parameters. More...
 

Macros

#define NET_ETH_ADDR_LEN   6U
 Ethernet MAC address length.
 
#define NET_ETH_MINIMAL_FRAME_SIZE   60
 Minimum Ethernet frame size.
 
#define NET_ETH_MTU   1500
 Ethernet MTU size.
 
#define ETH_NET_DEVICE_INIT(dev_id, name, init_fn, pm, data, config, prio, api, mtu)
 Create an Ethernet network interface and bind it to network device.
 
#define ETH_NET_DEVICE_INIT_INSTANCE(dev_id, name, instance, init_fn, pm, data, config, prio, api, mtu)
 Create multiple Ethernet network interfaces and bind them to network devices.
 
#define ETH_NET_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, prio, api, mtu)
 Like ETH_NET_DEVICE_INIT but taking metadata from a devicetree.
 
#define ETH_NET_DEVICE_DT_INST_DEFINE(inst, ...)    ETH_NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
 Like ETH_NET_DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT compatible.
 

Enumerations

enum  ethernet_hw_caps {
  ETHERNET_HW_TX_CHKSUM_OFFLOAD = BIT(0) , ETHERNET_HW_RX_CHKSUM_OFFLOAD = BIT(1) , ETHERNET_HW_VLAN = BIT(2) , ETHERNET_AUTO_NEGOTIATION_SET = BIT(3) ,
  ETHERNET_LINK_10BASE_T = BIT(4) , ETHERNET_LINK_100BASE_T = BIT(5) , ETHERNET_LINK_1000BASE_T = BIT(6) , ETHERNET_DUPLEX_SET = BIT(7) ,
  ETHERNET_PTP = BIT(8) , ETHERNET_QAV = BIT(9) , ETHERNET_PROMISC_MODE = BIT(10) , ETHERNET_PRIORITY_QUEUES = BIT(11) ,
  ETHERNET_HW_FILTERING = BIT(12) , ETHERNET_LLDP = BIT(13) , ETHERNET_HW_VLAN_TAG_STRIP = BIT(14) , ETHERNET_DSA_SLAVE_PORT = BIT(15) ,
  ETHERNET_DSA_MASTER_PORT = BIT(16) , ETHERNET_QBV = BIT(17) , ETHERNET_QBU = BIT(18) , ETHERNET_TXTIME = BIT(19) ,
  ETHERNET_TXINJECTION_MODE = BIT(20)
}
 Ethernet hardware capabilities. More...
 
enum  ethernet_if_types { L2_ETH_IF_TYPE_ETHERNET , L2_ETH_IF_TYPE_WIFI }
 Types of Ethernet L2. More...
 
enum  ethernet_checksum_support {
  ETHERNET_CHECKSUM_SUPPORT_NONE = NET_IF_CHECKSUM_NONE_BIT , ETHERNET_CHECKSUM_SUPPORT_IPV4_HEADER = NET_IF_CHECKSUM_IPV4_HEADER_BIT , ETHERNET_CHECKSUM_SUPPORT_IPV4_ICMP = NET_IF_CHECKSUM_IPV4_ICMP_BIT , ETHERNET_CHECKSUM_SUPPORT_IPV6_HEADER = NET_IF_CHECKSUM_IPV6_HEADER_BIT ,
  ETHERNET_CHECKSUM_SUPPORT_IPV6_ICMP = NET_IF_CHECKSUM_IPV6_ICMP_BIT , ETHERNET_CHECKSUM_SUPPORT_TCP = NET_IF_CHECKSUM_TCP_BIT , ETHERNET_CHECKSUM_SUPPORT_UDP = NET_IF_CHECKSUM_UDP_BIT
}
 Protocols that are supported by checksum offloading. More...
 

Functions

static bool net_eth_is_addr_broadcast (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is a broadcast address.
 
static bool net_eth_is_addr_all_zeroes (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is a all zeroes address.
 
static bool net_eth_is_addr_unspecified (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is unspecified.
 
static bool net_eth_is_addr_multicast (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is a multicast address.
 
static bool net_eth_is_addr_group (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is a group address.
 
static bool net_eth_is_addr_valid (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is valid.
 
static bool net_eth_is_addr_lldp_multicast (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is a LLDP multicast address.
 
static bool net_eth_is_addr_ptp_multicast (struct net_eth_addr *addr)
 Check if the Ethernet MAC address is a PTP multicast address.
 
const struct net_eth_addrnet_eth_broadcast_addr (void)
 Return Ethernet broadcast address.
 
void net_eth_ipv4_mcast_to_mac_addr (const struct in_addr *ipv4_addr, struct net_eth_addr *mac_addr)
 Convert IPv4 multicast address to Ethernet address.
 
void net_eth_ipv6_mcast_to_mac_addr (const struct in6_addr *ipv6_addr, struct net_eth_addr *mac_addr)
 Convert IPv6 multicast address to Ethernet address.
 
static enum ethernet_hw_caps net_eth_get_hw_capabilities (struct net_if *iface)
 Return ethernet device hardware capability information.
 
static int net_eth_get_hw_config (struct net_if *iface, enum ethernet_config_type type, struct ethernet_config *config)
 Return ethernet device hardware configuration information.
 
static int net_eth_vlan_enable (struct net_if *iface, uint16_t tag)
 Add VLAN tag to the interface.
 
static int net_eth_vlan_disable (struct net_if *iface, uint16_t tag)
 Remove VLAN tag from the interface.
 
static uint16_t net_eth_get_vlan_tag (struct net_if *iface)
 Return VLAN tag specified to network interface.
 
static struct net_ifnet_eth_get_vlan_iface (struct net_if *iface, uint16_t tag)
 Return network interface related to this VLAN tag.
 
static struct net_ifnet_eth_get_vlan_main (struct net_if *iface)
 Return main network interface that is attached to this VLAN tag.
 
static bool net_eth_is_vlan_enabled (struct ethernet_context *ctx, struct net_if *iface)
 Check if there are any VLAN interfaces enabled to this specific Ethernet network interface.
 
static bool net_eth_get_vlan_status (struct net_if *iface)
 Get VLAN status for a given network interface (enabled or not).
 
static bool net_eth_is_vlan_interface (struct net_if *iface)
 Check if the given interface is a VLAN interface.
 
void net_eth_carrier_on (struct net_if *iface)
 Inform ethernet L2 driver that ethernet carrier is detected.
 
void net_eth_carrier_off (struct net_if *iface)
 Inform ethernet L2 driver that ethernet carrier was lost.
 
int net_eth_promisc_mode (struct net_if *iface, bool enable)
 Set promiscuous mode either ON or OFF.
 
int net_eth_txinjection_mode (struct net_if *iface, bool enable)
 Set TX-Injection mode either ON or OFF.
 
int net_eth_mac_filter (struct net_if *iface, struct net_eth_addr *mac, enum ethernet_filter_type type, bool enable)
 Set or unset HW filtering for MAC address mac.
 
static const struct devicenet_eth_get_ptp_clock (struct net_if *iface)
 Return PTP clock that is tied to this ethernet network interface.
 
const struct devicenet_eth_get_ptp_clock_by_index (int index)
 Return PTP clock that is tied to this ethernet network interface index.
 
static int net_eth_get_ptp_port (struct net_if *iface)
 Return PTP port number attached to this interface.
 
static void net_eth_set_ptp_port (struct net_if *iface, int port)
 Set PTP port number attached to this interface.
 
static bool net_eth_type_is_wifi (struct net_if *iface)
 Check if the Ethernet L2 network interface can perform Wi-Fi.
 

Detailed Description

Ethernet.

This is not to be included by the application.