|
Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
|
Ethernet support functions. More...
Topics | |
| DSA tag protocol | |
| Definitions for DSA tag protocol. | |
| 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_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... | |
| struct | net_eth_mac_config |
| MAC address configuration. 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, ...) |
| Like ETH_NET_DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT compatible. | |
| #define | ETH_NET_L3_REGISTER(name, ptype, handler) |
| Ethernet L3 protocol register macro. | |
| #define | NET_ETH_MAC_DT_CONFIG_INIT(node_id) |
| Initialize the ethernet MAC config for the given DT node identifier. | |
| #define | NET_ETH_MAC_DT_INST_CONFIG_INIT(inst) |
| Like NET_ETH_MAC_DT_CONFIG_INIT 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_unicast (struct net_eth_addr *addr) |
| Check if the Ethernet MAC address is an unicast 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 net_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 net_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 or if priority tagged frames (tag 0) are supported. | |
| 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. | |
| static int | net_eth_mac_load (const struct net_eth_mac_config *cfg, uint8_t *mac_addr) |
| Load a MAC address from a MAC address configuration structure with the specified type. | |
| void | net_eth_carrier_set (struct net_if *iface, bool carrier_up) |
| Inform ethernet L2 driver that ethernet carrier is detected or was lost. | |
| static void | net_eth_carrier_on (struct net_if *iface) |
| Inform ethernet L2 driver that ethernet carrier is detected. | |
| static 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. | |
| const struct device * | net_eth_get_phy (struct net_if *iface) |
| Return the PHY device that is tied to this ethernet network interface. | |
| 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 bool | net_eth_type_is_wifi (struct net_if *iface) |
| Check if the Ethernet L2 network interface can perform Wi-Fi. | |
| static bool | net_eth_type_is_ethernet (struct net_if *iface) |
| Check if the Ethernet L2 network interface is cabled ethernet. | |
| static void | net_eth_set_if_type_wifi (struct net_if *iface) |
| Set the Ethernet interface type to Wi-Fi. | |
Ethernet support functions.
| #define ETH_NET_DEVICE_DT_DEFINE | ( | node_id, | |
| init_fn, | |||
| pm, | |||
| data, | |||
| config, | |||
| prio, | |||
| api, | |||
| mtu ) |
#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, | |
| ... ) |
#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_INST(inst) in the call to ETH_NET_DEVICE_DT_DEFINE. |
| ... | other parameters as expected by ETH_NET_DEVICE_DT_DEFINE. |
| #define ETH_NET_DEVICE_INIT | ( | dev_id, | |
| name, | |||
| init_fn, | |||
| pm, | |||
| data, | |||
| config, | |||
| prio, | |||
| api, | |||
| mtu ) |
#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 <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 ETH_NET_L3_REGISTER | ( | name, | |
| ptype, | |||
| handler ) |
#include <zephyr/net/ethernet.h>
Ethernet L3 protocol register macro.
| name | Name of the L3 protocol. |
| ptype | Ethernet protocol type. |
| handler | Handler function for this protocol type. |
| #define NET_ETH_ADDR_LEN 6U |
#include <zephyr/net/ethernet.h>
Ethernet MAC address length.
| #define NET_ETH_MAC_DT_CONFIG_INIT | ( | node_id | ) |
#include <zephyr/net/ethernet.h>
Initialize the ethernet MAC config for the given DT node identifier.
| node_id | Node identifier. |
| #define NET_ETH_MAC_DT_INST_CONFIG_INIT | ( | inst | ) |
#include <zephyr/net/ethernet.h>
Like NET_ETH_MAC_DT_CONFIG_INIT for an instance of a DT_DRV_COMPAT compatible.
| inst | Instance number. |
| #define NET_ETH_MINIMAL_FRAME_SIZE 60 |
#include <zephyr/net/ethernet.h>
Minimum Ethernet frame size.
| #define NET_ETH_MTU 1500 |
#include <zephyr/net/ethernet.h>
Ethernet MTU size.
#include <zephyr/net/ethernet.h>
Protocols that are supported by checksum offloading.
| enum ethernet_hw_caps |
#include <zephyr/net/ethernet.h>
Ethernet hardware capabilities.
| enum ethernet_if_types |
#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. |
| enum ethernet_stats_type |
#include <zephyr/net/ethernet.h>
Ethernet statistics type (bitmap).
| Enumerator | |
|---|---|
| ETHERNET_STATS_TYPE_COMMON | Common statistics only (excludes vendor statistics). |
| ETHERNET_STATS_TYPE_VENDOR | Vendor statistics only. |
| ETHERNET_STATS_TYPE_ALL | All statistics. |
| enum net_eth_mac_type |
#include <zephyr/net/ethernet.h>
MAC address configuration types.
| const struct net_eth_addr * net_eth_broadcast_addr | ( | void | ) |
#include <zephyr/net/ethernet.h>
Return Ethernet broadcast address.
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Inform ethernet L2 driver that ethernet carrier was lost.
This happens when cable is disconnected.
| iface | Network interface |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Inform ethernet L2 driver that ethernet carrier is detected.
This happens when cable is connected.
| iface | Network interface |
#include <zephyr/net/ethernet.h>
Inform ethernet L2 driver that ethernet carrier is detected or was lost.
This happens when cable is connected or disconnected.
| iface | Network interface |
| carrier_up | true if carrier is detected, false if carrier was lost |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Return ethernet device hardware capability information.
| iface | Network interface |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Return ethernet device hardware configuration information.
| iface | Network interface |
| type | configuration type |
| config | Ethernet configuration |
#include <zephyr/net/ethernet.h>
Return the PHY device that is tied to this ethernet network interface.
| iface | Network interface |
#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 <zephyr/net/ethernet.h>
Return PTP clock that is tied to this ethernet network interface index.
| index | Network interface index |
#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 <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 <zephyr/net/ethernet.h>
Get VLAN status for a given network interface (enabled or not).
| iface | Network interface |
#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 net_in_addr * | ipv4_addr, |
| struct net_eth_addr * | mac_addr ) |
#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 net_in6_addr * | ipv6_addr, |
| struct net_eth_addr * | mac_addr ) |
#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 <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 <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 <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 <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 <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 <zephyr/net/ethernet.h>
Check if the Ethernet MAC address is an unicast address.
| addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Check if the Ethernet MAC address is unspecified.
| addr | A valid pointer to a Ethernet MAC address. |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Check if the Ethernet MAC address is valid.
| addr | A valid pointer to a Ethernet MAC address. |
#include <zephyr/net/ethernet.h>
Check if there are any VLAN interfaces enabled to this specific Ethernet network interface or if priority tagged frames (tag 0) are supported.
Note that the iface must be the actual Ethernet interface and not the virtual VLAN interface.
| ctx | Ethernet context |
| iface | Ethernet network interface |
#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 <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) |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Load a MAC address from a MAC address configuration structure with the specified type.
In the case of a randomized MAC address, the universal vs local (U/L) bit is set to a locally administered address (LAA) and the unicast vs multicast (I/G) bit is cleared to make it a unicast address.
| cfg | The MAC address configuration. |
| mac_addr | The resulting MAC address buffer, needs a size of NET_ETH_ADDR_LEN bytes. |
| -ENODATA | No MAC address configuration data is loaded. |
| <0 | Negative errno code if failure. |
| 0 | If successful. |
< Ethernet MAC address length
#include <zephyr/net/ethernet.h>
Set promiscuous mode either ON or OFF.
| iface | Network interface |
| enable | on (true) or off (false) |
|
inlinestatic |
#include <zephyr/net/ethernet.h>
Set the Ethernet interface type to Wi-Fi.
| iface | Network interface |
#include <zephyr/net/ethernet.h>
Set TX-Injection mode either ON or OFF.
| iface | Network interface |
| enable | on (true) or off (false) |
#include <zephyr/net/ethernet.h>
Check if the Ethernet L2 network interface is cabled ethernet.
| iface | Pointer to network interface |
#include <zephyr/net/ethernet.h>
Check if the Ethernet L2 network interface can perform Wi-Fi.
| iface | Pointer to network interface |
#include <zephyr/net/ethernet.h>
Remove VLAN tag from the interface.
| iface | Interface to use. |
| tag | VLAN tag to remove |
#include <zephyr/net/ethernet.h>
Add VLAN tag to the interface.
| iface | Interface to use. |
| tag | VLAN tag to add |