4.3. RSTP

This is a simple demonstration example to setup a RSTP network which is a mode of the mstpd daemon that is provided in the Processors Linux SDK file system. This example setup is done from the Linux command line. Users that require automatic interface, bridge and msptd daemon setup at system initialization will need to do the steps necessary to implement this initialization method.

Note

RSTP functionality over PRU Ethernet is neither tested nor supported on AM335x and AM437x.


If you need a background in the bridge utility that Linux supports please refer to this link.

https://wiki.linuxfoundation.org/networking/bridge


The link above documents the kernel brctl utility that creates network bridges and the spanning tree protocol (STP) support provided by the kernel. To go beyond STP requires a user level daemon that will manage the tree topology and changes to that topology. The pre-built kernel binaries and file system do not require changes to use the mstpd daemon. RSTP mode of the mstpd daemon was tested on TI EVMs that have multiple CPSW or PRU ports. Multi-port boards will have dual mac mode enabled for the CPSW as out of the box configurations for TI EVMs. There are additional PRU-ICSS Ethernet ports available on the AM57x class IDK boards. This diagram shows one of the topologies used to test the setup.

../_images/Cpsw_rstp_mstpd_topology_1.jpg

3 node ring demonstrating port blocking on low cost link


Please note that the topology was tested across CPSW only ports, PRU-ICSS Ethernet only ports and a one CPSW and one PRU-ICSS port.


To set up the environment shown above, first on each board bring up the interfaces that will be used for the bridge with the ifconfig command. Next on each board a bridge must be created and then add in the two interfaces to the bridge. The bridge is then enabled in STP mode. Then as a last configuration step use the mstpctl utility to transition the bridge from STP to RSTP mode.

Setup the ports, IP addresses are not used for the Ethernet ports in a bridge.


ifconfig eth0 up

ifconfig eth1 up


Now create and setup bridge br0 using the brctl application.

brctl create br0

brctl addif br0 eth0

brctl addif br0 eth1

ifconfig br0 up


Now switch the bridge mode from stp to rstp using the mstpctl application

mstpctl setforcevers br0 rstp

Now look on each platform to verify where the root node is with these commands

mstpctl showbridge


4.3.1. RSTP with ICSS Switch Firmware

With ICSS switch firmware, RSTP can be supported with L2 forwarding offload on the ICSSs in AM57x IDK platforms.

Note

RSTP functionality over PRU Ethernet is neither tested nor supported on AM335x and AM437x.

Briefly, in this case, the PRU ethernet driver together with the switch firmware are responsible for creating a forwarding database (FDB) table. MAC address in a frame received on a physical port is learned dynamically and a corresponding entry is created in the FDB table. When frames with a learned MAC address as the destination address is received, it will be cut-through forwarded to the port indicated in the FDB entry directly without involving the host.

To set up a RSTP network with ICSS switch firmware, connect 3 AM571x-IDK as follows:

../_images/rstp_with_switch_firmware.jpg
Example: 3 node ring demonstrating RSTP with switch firmware

Note

The ICSS switch firmware has multicast filtering enabled by default, hence it’s important to ensure that STP multicast address 01:80:c2:00:00:00 is enabled in the ICSS switch firmware. The STP multicast address can be added manually to the bridge netdev once it’s created, like: ip maddr add 01:80:c2:00:00:00 dev br0, and PRU ethernet driver will ensure it’s configured properly when PRU netdev added to the bridge.


Note

Some rootfs systems, like systemd, may assign random, local MAC address to the bridge netdev by default. It’s recommended to reassign bridge netdev MAC address to the MAC address of the one of the child interfaces. Like: ip link set dev br0 address $(cat /sys/class/net/<intf>/address)

Boot up the IDKs as follows:

  1. Boot IDKs into linux prompt.
  2. Make sure the following lines appear in the boot log:
[   30.617491] prueth pruss1_eth: TI PRU ethernet initialized: Dual EMAC mode
[   31.207474] prueth pruss2_eth: TI PRU ethernet initialized: Dual EMAC mode

Note: timing is for reference only.

  1. Run the following script rstp.sh on each IDK.

The script can be run with default (eth2, eth3, br0) or user parameters, like rstp.sh pru10 pru11

#!/bin/bash
# rstp.sh

set -x #echo on

ETH1=${1:-eth2}
ETH2=${2:-eth3}
BR0=${4:-br0}

mstpd
sleep 1

ip link set dev $ETH1 up
sleep 1

ip link set dev $ETH2 up
sleep 1

brctl addbr $BR0
sleep 1

# manually add STP MC address to enable it in PRU MC filter table
ip maddr add 01:80:c2:00:00:00 dev $BR0

ip link set dev $BR0 address $(cat /sys/class/net/$ETH1/address)

brctl addif $BR0 $ETH1
sleep 1

brctl addif $BR0 $ETH2
sleep 1

brctl stp $BR0  on
sleep 1

mstpctl setforcevers $BR0 rstp
sleep 1

ip link set dev $BR0 up
sleep 1

mstpctl showbridge

The script

  1. starts mstpd daemon
  2. crates a bridge interface br0 on eth2 and eth3
  3. enables rstp on the bridge br0
  4. shows some information about the bridge
  1. Issue command to show port information on each IDK:
$ mstpctl showport br0 eth2
$ mstpctl showport br0 eth3

sample output:

eth2  8.001 forw 8.000.70:FF:76:1C:16:EF 8.000.70:FF:76:1C:16:EF 8.001 Desg

where

forw is the port state

Desg is the port role

Note 1: In the test setup shown above , the port state and port role are shown in (state, role), eg. (f,R) - port state is forwarding and port role is Root.

Note 2: The (state, role) pairs may show on different DUTs but there must be a discard state appears. This discard state is a result of the RSTP protocol which breaks the cyclic connection into a tree (in this case, a serial connection.

Note 3: In step 3 as soon as the both interface are added to the Linux bridge, the Ethernet device automatically change mode to SWITCH. When the interface is brought up, driver loads SWITCH firmware and brings up the PRUs in switch mode. Similarly when last interface is removed from the Linux bridge, the driver change the Etherent type to Dual EMAC. Thus Dual EMAC firmware is loaded and run at the PRUs when next time interface is brought up.

  1. In step 4, make sure the cyclic connection is broken by a discard state in one of the ports of one of the DUTs.

    In setup in step 1, it is Dut2.eth2.

  2. configure an IP address on br0 on any one DUT and another IP address of the same subnet on another DUT. E.g.

    on Dut1: $ ip addr add 192.168.1.1/24 dev br0

    on Dut3: $ ip addr add 192.168.1.2/24 dev br0

  3. Make sure ping works fron Dut1 to Dut3.

  4. Unplug any of the 3 cables and make sure the ping continues to work each time.