Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
Ethernet support functions. More...
Modules | |
Ethernet MII Support Functions | |
Ethernet MII (media independent interface) functions. | |
IEEE 802.3 management interface | |
Definitions for IEEE 802.3 management interface. | |
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. | |
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_addr * | net_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_if * | net_eth_get_vlan_iface (struct net_if *iface, uint16_t tag) |
Return network interface related to this VLAN tag. | |
static struct net_if * | net_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 device * | net_eth_get_ptp_clock (struct net_if *iface) |
Return PTP clock that is tied to this ethernet network interface. | |
const struct device * | net_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. | |
Ethernet support functions.
#include <include/zephyr/net/ethernet.h>
Like ETH_NET_DEVICE_INIT but taking metadata from a devicetree.
Create an Ethernet network interface and bind it to network device.
node_id | The devicetree node identifier. |
init_fn | Address to the init function of the driver. |
pm | Reference to struct pm_device associated with the device. (optional). |
data | Pointer to the device's private data. |
config | The address to the structure containing the configuration information for this instance of the driver. |
prio | The initialization level at which configuration occurs. |
api | Provides an initial pointer to the API function struct used by the driver. Can be NULL. |
mtu | Maximum transfer unit in bytes for this network interface. |
#define ETH_NET_DEVICE_DT_INST_DEFINE | ( | inst, | |
... | |||
) | ETH_NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__) |
#include <include/zephyr/net/ethernet.h>
Like ETH_NET_DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT compatible.
inst | instance number. This is replaced by DT_DRV_COMPAT(inst) in the call to ETH_NET_DEVICE_DT_DEFINE. |
... | other parameters as expected by ETH_NET_DEVICE_DT_DEFINE. |
#include <include/zephyr/net/ethernet.h>
Create an Ethernet network interface and bind it to network device.
dev_id | Network device id. |
name | The name this instance of the driver exposes to the system. |
init_fn | Address to the init function of the driver. |
pm | Reference to struct pm_device associated with the device. (optional). |
data | Pointer to the device's private data. |
config | The address to the structure containing the configuration information for this instance of the driver. |
prio | The initialization level at which configuration occurs. |
api | Provides an initial pointer to the API function struct used by the driver. Can be NULL. |
mtu | Maximum transfer unit in bytes for this network interface. |
#define ETH_NET_DEVICE_INIT_INSTANCE | ( | dev_id, | |
name, | |||
instance, | |||
init_fn, | |||
pm, | |||
data, | |||
config, | |||
prio, | |||
api, | |||
mtu | |||
) |
#include <include/zephyr/net/ethernet.h>
Create multiple Ethernet network interfaces and bind them to network devices.
If your network device needs more than one instance of a network interface, use this macro below and provide a different instance suffix each time (0, 1, 2, ... or a, b, c ... whatever works for you)
dev_id | Network device id. |
name | The name this instance of the driver exposes to the system. |
instance | Instance identifier. |
init_fn | Address to the init function of the driver. |
pm | Reference to struct pm_device associated with the device. (optional). |
data | Pointer to the device's private data. |
config | The address to the structure containing the configuration information for this instance of the driver. |
prio | The initialization level at which configuration occurs. |
api | Provides an initial pointer to the API function struct used by the driver. Can be NULL. |
mtu | Maximum transfer unit in bytes for this network interface. |
#define NET_ETH_ADDR_LEN 6U |
#include <include/zephyr/net/ethernet.h>
Ethernet MAC address length.
#define NET_ETH_MINIMAL_FRAME_SIZE 60 |
#include <include/zephyr/net/ethernet.h>
Minimum Ethernet frame size.
#define NET_ETH_MTU 1500 |
#include <include/zephyr/net/ethernet.h>
Ethernet MTU size.
#include <include/zephyr/net/ethernet.h>
Protocols that are supported by checksum offloading.
enum ethernet_hw_caps |
#include <include/zephyr/net/ethernet.h>
Ethernet hardware capabilities.
enum ethernet_if_types |
#include <include/zephyr/net/ethernet.h>
Types of Ethernet L2.
Enumerator | |
---|---|
L2_ETH_IF_TYPE_ETHERNET | IEEE 802.3 Ethernet (default) |
L2_ETH_IF_TYPE_WIFI | IEEE 802.11 Wi-Fi. |
const struct net_eth_addr * net_eth_broadcast_addr | ( | void | ) |
#include <include/zephyr/net/ethernet.h>
Return Ethernet broadcast address.
void net_eth_carrier_off | ( | struct net_if * | iface | ) |
#include <include/zephyr/net/ethernet.h>
Inform ethernet L2 driver that ethernet carrier was lost.
This happens when cable is disconnected.
iface | Network interface |
void net_eth_carrier_on | ( | struct net_if * | iface | ) |
#include <include/zephyr/net/ethernet.h>
Inform ethernet L2 driver that ethernet carrier is detected.
This happens when cable is connected.
iface | Network interface |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Return ethernet device hardware capability information.
iface | Network interface |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Return ethernet device hardware configuration information.
iface | Network interface |
type | configuration type |
config | Ethernet configuration |
#include <include/zephyr/net/ethernet.h>
Return PTP clock that is tied to this ethernet network interface.
iface | Network interface |
const struct device * net_eth_get_ptp_clock_by_index | ( | int | index | ) |
#include <include/zephyr/net/ethernet.h>
Return PTP clock that is tied to this ethernet network interface index.
index | Network interface index |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Return PTP port number attached to this interface.
iface | Network interface |
#include <include/zephyr/net/ethernet.h>
Return network interface related to this VLAN tag.
iface | Main network interface (not the VLAN one). |
tag | VLAN tag |
#include <include/zephyr/net/ethernet.h>
Return main network interface that is attached to this VLAN tag.
iface | VLAN network interface. This is used to get the pointer to ethernet L2 context |
#include <include/zephyr/net/ethernet.h>
Get VLAN status for a given network interface (enabled or not).
iface | Network interface |
#include <include/zephyr/net/ethernet.h>
Return VLAN tag specified to network interface.
Note that the interface parameter must be the VLAN interface, and not the Ethernet one.
iface | VLAN network interface. |
void net_eth_ipv4_mcast_to_mac_addr | ( | const struct in_addr * | ipv4_addr, |
struct net_eth_addr * | mac_addr | ||
) |
#include <include/zephyr/net/ethernet.h>
Convert IPv4 multicast address to Ethernet address.
ipv4_addr | IPv4 multicast address |
mac_addr | Output buffer for Ethernet address |
void net_eth_ipv6_mcast_to_mac_addr | ( | const struct in6_addr * | ipv6_addr, |
struct net_eth_addr * | mac_addr | ||
) |
#include <include/zephyr/net/ethernet.h>
Convert IPv6 multicast address to Ethernet address.
ipv6_addr | IPv6 multicast address |
mac_addr | Output buffer for Ethernet address |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is a all zeroes address.
addr | A valid pointer to an Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is a broadcast address.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is a group address.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is a LLDP multicast address.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is a multicast address.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is a PTP multicast address.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is unspecified.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet MAC address is valid.
addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Check if there are any VLAN interfaces enabled to this specific Ethernet network interface.
Note that the iface must be the actual Ethernet interface and not the virtual VLAN interface.
ctx | Ethernet context |
iface | Ethernet network interface |
#include <include/zephyr/net/ethernet.h>
Check if the given interface is a VLAN interface.
iface | Network interface |
int net_eth_mac_filter | ( | struct net_if * | iface, |
struct net_eth_addr * | mac, | ||
enum ethernet_filter_type | type, | ||
bool | enable | ||
) |
#include <include/zephyr/net/ethernet.h>
Set or unset HW filtering for MAC address mac
.
iface | Network interface |
mac | Pointer to an ethernet MAC address |
type | Filter type, either source or destination |
enable | Set (true) or unset (false) |
#include <include/zephyr/net/ethernet.h>
Set promiscuous mode either ON or OFF.
iface | Network interface |
enable | on (true) or off (false) |
|
inlinestatic |
#include <include/zephyr/net/ethernet.h>
Set PTP port number attached to this interface.
iface | Network interface |
port | Port number to set |
#include <include/zephyr/net/ethernet.h>
Set TX-Injection mode either ON or OFF.
iface | Network interface |
enable | on (true) or off (false) |
#include <include/zephyr/net/ethernet.h>
Check if the Ethernet L2 network interface can perform Wi-Fi.
iface | Pointer to network interface |
#include <include/zephyr/net/ethernet.h>
Remove VLAN tag from the interface.
iface | Interface to use. |
tag | VLAN tag to remove |
#include <include/zephyr/net/ethernet.h>
Add VLAN tag to the interface.
iface | Interface to use. |
tag | VLAN tag to add |