Part Number: AM6422
Hello,
We are developing on the AM6422 platform using the R5F1-0 core, and we are using the CPSW Ethernet module in switch mode. When received Ethernet data is identified as a GOOSE packet, it is written to shared memory. We use a hardware spinlock for synchronization during this write operation.
Our system consists of 12 terminals connected in a cascade topology. In our current simulation experiment, we connected the Ethernet ports of the head and tail terminals to the same external switch, which creates a physical network loop and causes a network storm.
Consequently, the GOOSE packets continuously accumulate on the network, and the terminals receive an exponentially increasing number of GOOSE packets, leading to highly frequent writes to the shared memory. After running for about 10 minutes, tracing revealed that acquiring the spinlock fails. Due to the strict real-time requirements of GOOSE data, we must use a busy-wait (spin-wait) mechanism when waiting for the lock. As a result, even after the storm stops, the Ethernet receive task remains stuck waiting for the lock in the shared memory write function, causing the Ethernet subsystem to become unresponsive.
We have monitored the lock and unlock counters, and they are perfectly consistent. There is no lock leakage (e.g., a lock being acquired without being released). We would like to know if there are any issues with our lock operations, and we kindly request your suggestions. Additionally, how should we handle or mitigate this network storm scenario?Our lock operation code is attached below.
static void sharemem_lock(uint32_t lockNum)
{
int32_t status;
uint32_t retry = 0;
/* Spin till lock is acquired */
while(1U)
{
status = Spinlock_lock(spinlockBaseAddr, lockNum);
if(status == SPINLOCK_LOCK_STATUS_FREE)
{
break; /* Free and taken */
}
}}