Other Parts Discussed in Thread: TLK105L, AM5718
We are currently working on integrating RSTP protocol into our design based on AM5701 processor, which was recently ported from SDK 06.02.00.81 to SDK 08.02.01.00. We employed the example script provided by TI in the related application note (Industrial_Protocols_RSTP) and we realized that there was no hardware offloading on PRUs. Instead of changing to switch mode by prueth driver and load ti-pruss/am57xx-pru0/1-prusw-fw.elf firmware into PRUs, the default ti-pruss/am57xx-pru0/1-prueth-fw.elf firmware is loaded:
root@am57xx-evm:~# cat /sys/class/remoteproc/remoteproc*/firmware
dra7-ipu1-fw.xem4
dra7-ipu2-fw.xem4
dra7-dsp1-fw.xe66
am57xx-pru1_0-fw
am57xx-pru1_1-fw
ti-pruss/am57xx-pru0-prueth-fw.elf
ti-pruss/am57xx-pru1-prueth-fw.elf
According to other thread (https://e2e.ti.com/support/processors-group/processors/f/processors-forum/945142/am5708-rstp-performance-issue-in-am57xx-idk) created by a colleague three years ago, in SDK 6.02, the change to switch mode was performed by applying the l2-fw-offload feature on both interfaces through ethtool. We found one similar feature available for SDK 8.02 but it is showed as fixed so we cannot put it on.
root@predixedge:~# ethtool -k eth1 | grep l2
l2-fwd-offload: on [fixed]
root@predixedge:~# ethtool -k eth2 | grep l2
l2-fwd-offload: on [fixed]
Taking a look into the code (prueth_core.c) the "eth_type" is assigned in prueth_change_to_switch_mode() (prueth->eth_type = PRUSS_ETHTYPE_SWITCH;), but that function is only called from prueth_port_offload_fwd_mark_update(), which in turn is called by prueth_ndev_port_link() and prueth_ndev_port_unlink(). What is happening is that prueth_ndev_event() would call prueth_ndev_port_link() on NETDEV_CHANGEUPPER event, but the call to prueth_sw_port_dev_check() will return "false" unless NETIF_F_HW_HSR_TAG_RM is set. Well, it doesn't make a lot of sense to have that HSR flag for the SW firmware... but when that flag is enabled, we have even seen the prusw firmware loaded sometimes!
We did some investigation on the prueth_core.c file history in ti-linux-kernel repo (https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/net/ethernet/ti?h=ti-rt-linux-5.10.y) and found the following:
- This commits added support for RSTP in April 2021: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/drivers/net/ethernet/ti/prueth_core.c?h=ti-rt-linux-5.10.y&id=c4b5529b070dfdedf85b4b1cf6dc0167af29f87d --> In this commit the NETIF_F_HW_L2FW_DOFFLOAD was introduced, and was used in prueth_sw_port_dev_check() what caused the SW firmware to be loaded.
- Then in July 2021 this commit added HSR/PRP: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/drivers/net/ethernet/ti/prueth_core.c?h=ti-rt-linux-5.10.y&id=d2e8eb5a46ec7216223407be3d3840648f554be0 --> This commit replaced the NETIF_F_HW_L2FW_DOFFLOAD by NETIF_F_HW_HSR_FWD and NETIF_F_HW_HSR_TAG_RM:
@@ -2267,12 +2548,22 @@ static int prueth_netdev_init(struct prueth *prueth,
ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;- if (of_device_is_compatible(prueth->dev->of_node, "ti,am57-prueth"))- ndev->features |= NETIF_F_HW_L2FW_DOFFLOAD;+ if (prueth->support_lre)+ ndev->hw_features |= (NETIF_F_HW_HSR_FWD | NETIF_F_HW_HSR_TAG_RM);++ ndev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; -
And in a follow-up commit from the same time https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/drivers/net/ethernet/ti/prueth_core.c?h=ti-rt-linux-5.10.y&id=25fc691922bd7da8941b044df9b9a10c62188db8 prueth_sw_port_dev_check() is modified to check NETIF_F_HW_HSR_TAG_RM flag instead of NETIF_F_HW_L2FW_DOFFLOAD.
We believe that RSTP offloading was broken unintentionally when HSR/PRP was introduced. Based on these commits, we did the modifications below to the prueth_core.c driver to see if with this the prusw firmware would load, and it worked well. We are doing some tests right now to verify that the forwarding is actually being done in the PRU firmware instead of in the linux driver.
root@predixedge:~# cat /sys/class/remoteproc/remoteproc*/firmware
dra7-ipu1-fw.xem4
dra7-ipu2-fw.xem4
dra7-dsp1-fw.xe66
am57xx-pru1_0-fw
am57xx-pru1_1-fw
ti-pruss/am57xx-pru0-prusw-fw.elf
ti-pruss/am57xx-pru1-prusw-fw.elf