I have implemented a phy loopback self-test procedure in ti-linux-kernel (branch=ti-rt-linux-5.4.y ; commit=3be7c8fa970782c88c2a188f7310ccc7256121f7) git repository for the drivers/net/ethernet/ti/cpsw.c driver. It is currently working on my am5718-idk board with both cpsw interfaces (the gmac is configured in dual-emac mode).
Currently i have the following limitations :
- The test may fail if we run it on both interfaces at the same time (adding a lock should do the trick)
- The test does not work in single emac mode. I did not investigate on this, i'm pretty sure there is just a little missing thing to make it work in this mode.
If you are interested, i can provide you with the patch for reviewal and (if it is good enough, of course) integration in your kernel.