Well you could try opening the data sheet for the LAN8742 (presuming that is the PHY chip you're using, you mention it but you don't actually
say) search for the word "loopback" and you'll find both the control register bits to enable near and far end loopback modes, and descriptions.
USB being having an intrinsically master/slave relationship between hosts and devices it isn't really possible to do a meaningful loopback test. I suppose some USB PHYs may have some sort of loopback-like test mode but I've never looked for or noticed one.
And of the responders, only mikeselectricstuff seems to understand what
"loopback" means. It means, usually physically, looping the communications medium back on itself so that anything you send out as a transmission comes immediately back to you, unaltered, as a receive signal. This enables you to do a simple bit by bit test that you're receiving what you send, or calculate statistics like bit error rate on the raw physical medium. You can have near-end loopback, where you make the loop at the outbound interface on a device, and far-end loopback, where you make the loop at the distant end of a circuit or at progressive points on the way to the distant end. The whole point is to enable one to test the
physical connection without getting any other systems involved (e.g. pinging) as you have no way of knowing if they are operating correctly.
Sometimes referred to as hairpining* because a crude way of doing it was to borrow a hairpin from a secretary and physically stuff the ends of it into a comms device's socket's tx and rx pins - not recommended. For 10/100Base-T Ethernet on RJ45s you can wire a plug to cross the receive and transmit pairs. (Gigabit ethernet gets more involved at the signalling level and switches have OAM modes to provide loopback, not quite as satisfactory as literally testing just the wires in the way a classic physical loopback does.) Most Ethernet PHYs will have a test mode where you can command the PHY to cross connect its tx and rx paths just before they leave the chip.
Loopback plug

For telecoms E1 links (
i.e. PDH) and similar on standard coax patch panels there were/are 'U-links' made specifically to allow the adjacent tx and rx connectors to be joined to form a far-end loopback. In fact it was standard practice to leave a physically ready, but not in-service, circuit with a U-link in place so that the remote end could test the circuit without it having to be fully commissioned (seeing a far-end loopback was also a hint that the far-end hadn't been commissioned and it was time to kick somebody to finish patching it to where it was supposed to be going).
U-link

*Not to be confused with
hairpining traffic in voice networks which refers to erroneously routing traffic back to its originating network.