Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Ethernet Bridge Spanning Tree API

Rapid Spanning Tree Protocol for Ethernet bridges. More...

Data Structures

struct  eth_bridge_stp_status
 Spanning tree state of a bridge. More...
struct  eth_bridge_stp_port_status
 Spanning tree state of a bridge port. More...
struct  eth_bridge_stp_port_event
 Information of the NET_EVENT_ETHERNET_BRIDGE_PORT_STATE event. More...
struct  eth_bridge_stp_root_event
 Information of the NET_EVENT_ETHERNET_BRIDGE_NEW_ROOT event. More...
struct  eth_bridge_stp_topology_event
 Information of the NET_EVENT_ETHERNET_BRIDGE_TOPOLOGY_CHANGE event. More...

Enumerations

enum  eth_bridge_stp_role {
  ETH_BRIDGE_STP_ROLE_DISABLED , ETH_BRIDGE_STP_ROLE_ROOT , ETH_BRIDGE_STP_ROLE_DESIGNATED , ETH_BRIDGE_STP_ROLE_ALTERNATE ,
  ETH_BRIDGE_STP_ROLE_BACKUP
}
 Port Role (IEEE Std 802.1Q-2014 13.27.66). More...
enum  eth_bridge_stp_version { ETH_BRIDGE_STP_VERSION_STP = 0 , ETH_BRIDGE_STP_VERSION_RSTP = 2 }
 Force Protocol Version (IEEE Std 802.1Q-2014 13.7.2). More...
enum  eth_bridge_stp_p2p { ETH_BRIDGE_STP_P2P_AUTO , ETH_BRIDGE_STP_P2P_ON , ETH_BRIDGE_STP_P2P_OFF }
 Point-to-point setting of a port (IEEE Std 802.1Q-2014 13.28.16). More...

Functions

int eth_bridge_stp_enable (struct net_if *br, bool enable)
 Start or stop the spanning tree protocol on a bridge.
int eth_bridge_stp_get_status (struct net_if *br, struct eth_bridge_stp_status *status)
 Get the spanning tree state of a bridge.
int eth_bridge_stp_port_get_status (struct net_if *br, struct net_if *iface, struct eth_bridge_stp_port_status *status)
 Get the spanning tree state of a bridge port.
int eth_bridge_stp_set_bridge_priority (struct net_if *br, uint16_t priority)
 Set the Bridge Priority.
int eth_bridge_stp_set_times (struct net_if *br, uint8_t max_age, uint8_t forward_delay)
 Set the Bridge Max Age and Bridge Forward Delay.
int eth_bridge_stp_set_tx_hold_count (struct net_if *br, uint8_t count)
 Set the Transmit Hold Count.
int eth_bridge_stp_set_version (struct net_if *br, enum eth_bridge_stp_version version)
 Set the Force Protocol Version.
int eth_bridge_stp_port_set_priority (struct net_if *br, struct net_if *iface, uint8_t priority)
 Set the priority of a bridge port.
int eth_bridge_stp_port_set_path_cost (struct net_if *br, struct net_if *iface, uint32_t cost)
 Set the Port Path Cost of a bridge port.
int eth_bridge_stp_port_set_edge (struct net_if *br, struct net_if *iface, bool admin_edge, bool auto_edge)
 Set how a bridge port detects that it is an Edge Port.
int eth_bridge_stp_port_set_p2p (struct net_if *br, struct net_if *iface, enum eth_bridge_stp_p2p p2p)
 Set whether a bridge port is attached to a point-to-point link.
int eth_bridge_stp_port_mcheck (struct net_if *br, struct net_if *iface)
 Make a bridge port check whether STP bridges are still attached.

Detailed Description

Rapid Spanning Tree Protocol for Ethernet bridges.

Since
4.6
Version
0.1.0

Enumeration Type Documentation

◆ eth_bridge_stp_p2p

#include <zephyr/net/ethernet_bridge_stp.h>

Point-to-point setting of a port (IEEE Std 802.1Q-2014 13.28.16).

Enumerator
ETH_BRIDGE_STP_P2P_AUTO 

Point-to-point if the link is full duplex.

ETH_BRIDGE_STP_P2P_ON 

The port is attached to a point-to-point link.

ETH_BRIDGE_STP_P2P_OFF 

The port is attached to a shared LAN.

◆ eth_bridge_stp_role

#include <zephyr/net/ethernet_bridge_stp.h>

Port Role (IEEE Std 802.1Q-2014 13.27.66).

Enumerator
ETH_BRIDGE_STP_ROLE_DISABLED 

The port is disabled, or the protocol is off.

ETH_BRIDGE_STP_ROLE_ROOT 

The port is the best path to the root bridge.

ETH_BRIDGE_STP_ROLE_DESIGNATED 

The port connects its LAN to the root bridge.

ETH_BRIDGE_STP_ROLE_ALTERNATE 

An alternate path to the root bridge, blocked.

ETH_BRIDGE_STP_ROLE_BACKUP 

A backup path to a LAN another port of this bridge connects, blocked.

◆ eth_bridge_stp_version

#include <zephyr/net/ethernet_bridge_stp.h>

Force Protocol Version (IEEE Std 802.1Q-2014 13.7.2).

Enumerator
ETH_BRIDGE_STP_VERSION_STP 

STP compatible: STP BPDUs and no rapid transitions.

ETH_BRIDGE_STP_VERSION_RSTP 

RSTP, the default.

Function Documentation

◆ eth_bridge_stp_enable()

int eth_bridge_stp_enable ( struct net_if * br,
bool enable )

#include <zephyr/net/ethernet_bridge_stp.h>

Start or stop the spanning tree protocol on a bridge.

The protocol is off by default and the bridge then forwards on every port. When started, every port discards frames until the protocol has decided its role. When stopped, every port forwards again and the learned FDB entries of the bridge are removed.

The protocol blocks a port by not forwarding frames from and to it in software. A port whose device forwards frames to its other ports in hardware (a DSA user port or ETHERNET_HW_PORT_FORWARDING) cannot be blocked that way, unless the device also reports ETHERNET_HW_STP_PORT_STATE: the protocol then sets the port state and flushes the learned addresses in hardware too. Without it the protocol does not start on a bridge with such a port, and such a port cannot be added while it runs.

The Bridge Identifier is made of the Bridge Priority and the MAC address of the bridge interface. Use a stable bridge MAC address, as a random one changes the Bridge Identifier on every boot.

Parameters
brBridge interface
enabletrue to start, false to stop
Return values
0The protocol was started or stopped.
-EALREADYThe protocol was already in that state.
-EINVALbr is not a bridge interface.
-ENOTSUPA port of br forwards frames to other ports in hardware, as DSA switch ports and the ADIN2111 do, and its device cannot block it.

◆ eth_bridge_stp_get_status()

int eth_bridge_stp_get_status ( struct net_if * br,
struct eth_bridge_stp_status * status )

#include <zephyr/net/ethernet_bridge_stp.h>

Get the spanning tree state of a bridge.

Parameters
brBridge interface
statusFilled with the state of br
Return values
0The status was filled.
-EINVALbr is not a bridge interface.

◆ eth_bridge_stp_port_get_status()

int eth_bridge_stp_port_get_status ( struct net_if * br,
struct net_if * iface,
struct eth_bridge_stp_port_status * status )

#include <zephyr/net/ethernet_bridge_stp.h>

Get the spanning tree state of a bridge port.

Parameters
brBridge interface
ifaceEthernet interface bridged by br
statusFilled with the state of the port of iface
Return values
0The status was filled.
-EINVALbr is not a bridge interface.
-ENOENTiface is not a port of br.

◆ eth_bridge_stp_port_mcheck()

int eth_bridge_stp_port_mcheck ( struct net_if * br,
struct net_if * iface )

#include <zephyr/net/ethernet_bridge_stp.h>

Make a bridge port check whether STP bridges are still attached.

A port that has heard an STP bridge keeps sending STP BPDUs. This makes it send RST BPDUs again, and fall back once more if an STP bridge is still there.

Parameters
brBridge interface
ifaceEthernet interface bridged by br
Return values
0The check was started.
-EINVALbr is not a bridge interface.
-ENOENTiface is not a port of br.

◆ eth_bridge_stp_port_set_edge()

int eth_bridge_stp_port_set_edge ( struct net_if * br,
struct net_if * iface,
bool admin_edge,
bool auto_edge )

#include <zephyr/net/ethernet_bridge_stp.h>

Set how a bridge port detects that it is an Edge Port.

An Edge Port has no bridge behind it and forwards without delay.

Parameters
brBridge interface
ifaceEthernet interface bridged by br
admin_edgeThe port is an Edge Port from the start, false by default
auto_edgeThe port becomes an Edge Port when it receives no BPDU, true by default
Return values
0The setting was stored.
-EINVALbr is not a bridge interface.
-ENOENTiface is not a port of br.

◆ eth_bridge_stp_port_set_p2p()

int eth_bridge_stp_port_set_p2p ( struct net_if * br,
struct net_if * iface,
enum eth_bridge_stp_p2p p2p )

#include <zephyr/net/ethernet_bridge_stp.h>

Set whether a bridge port is attached to a point-to-point link.

Rapid transitions to forwarding need a point-to-point link.

Parameters
brBridge interface
ifaceEthernet interface bridged by br
p2pPoint-to-point setting, ETH_BRIDGE_STP_P2P_AUTO by default
Return values
0The setting was stored.
-EINVALbr is not a bridge interface or p2p is not valid.
-ENOENTiface is not a port of br.

◆ eth_bridge_stp_port_set_path_cost()

int eth_bridge_stp_port_set_path_cost ( struct net_if * br,
struct net_if * iface,
uint32_t cost )

#include <zephyr/net/ethernet_bridge_stp.h>

Set the Port Path Cost of a bridge port.

Parameters
brBridge interface
ifaceEthernet interface bridged by br
cost1 to 200000000, or 0 to derive it from the link speed (IEEE Std 802.1Q-2014 Table 13-4), the default
Return values
0The cost was set.
-EINVALbr is not a bridge interface or cost is not valid.
-ENOENTiface is not a port of br.

◆ eth_bridge_stp_port_set_priority()

int eth_bridge_stp_port_set_priority ( struct net_if * br,
struct net_if * iface,
uint8_t priority )

#include <zephyr/net/ethernet_bridge_stp.h>

Set the priority of a bridge port.

Parameters
brBridge interface
ifaceEthernet interface bridged by br
priority0 to 240 in steps of 16, 128 by default
Return values
0The priority was set.
-EINVALbr is not a bridge interface or priority is not valid.
-ENOENTiface is not a port of br.

◆ eth_bridge_stp_set_bridge_priority()

int eth_bridge_stp_set_bridge_priority ( struct net_if * br,
uint16_t priority )

#include <zephyr/net/ethernet_bridge_stp.h>

Set the Bridge Priority.

The bridge with the best (numerically lowest) priority becomes the root.

Parameters
brBridge interface
priority0 to 61440 in steps of 4096, 32768 by default
Return values
0The priority was set.
-EINVALbr is not a bridge interface or priority is not valid.

◆ eth_bridge_stp_set_times()

int eth_bridge_stp_set_times ( struct net_if * br,
uint8_t max_age,
uint8_t forward_delay )

#include <zephyr/net/ethernet_bridge_stp.h>

Set the Bridge Max Age and Bridge Forward Delay.

The values must satisfy 2 * (forward_delay - 1) >= max_age >= 6.

Parameters
brBridge interface
max_ageBridge Max Age, 6 to 40 seconds, 20 by default
forward_delayBridge Forward Delay, 4 to 30 seconds, 15 by default
Return values
0The times were set.
-EINVALbr is not a bridge interface or a value is not valid.

◆ eth_bridge_stp_set_tx_hold_count()

int eth_bridge_stp_set_tx_hold_count ( struct net_if * br,
uint8_t count )

#include <zephyr/net/ethernet_bridge_stp.h>

Set the Transmit Hold Count.

Parameters
brBridge interface
countMost BPDUs a port sends in one second, 1 to 10, 6 by default
Return values
0The count was set.
-EINVALbr is not a bridge interface or count is not valid.

◆ eth_bridge_stp_set_version()

int eth_bridge_stp_set_version ( struct net_if * br,
enum eth_bridge_stp_version version )

#include <zephyr/net/ethernet_bridge_stp.h>

Set the Force Protocol Version.

Restarts the protocol on all ports of a running bridge.

Parameters
brBridge interface
versionProtocol version
Return values
0The version was set.
-EINVALbr is not a bridge interface or version is not valid.