Re: [PATCH net-next v2] net: phylink: add phylink_pcs_loopback() method for PCS loopback support

From: Maxime Chevallier

Date: Tue Jul 28 2026 - 04:50:48 EST


Hi,

On 7/27/26 14:07, Zxyan Zhu wrote:
> Some Ethernet MAC drivers (such as stmmac) need to perform PCS-level
> loopback for selftest purposes when no external PHY is present. Add a
> new phylink_pcs_loopback() method that allows MAC drivers to request
> PCS loopback mode through the phylink framework.
>
> Implement the pcs_loopback callback in the stmmac integrated PCS
> using the GMAC_AN_CTRL_ELE register bit. Add a helper function
> stmmac_selftest_get_pcs() in stmmac selftests to unify PCS lookup
> across glue driver PCS and integrated PCS. Update the selftest
> enable/disable paths to use the new helper.
>
> Signed-off-by: Zxyan Zhu <zxyan0222@xxxxxxxxx>

I'm actually seriously wondering if we shouldn't just stick to MAC loopback only
for stmmac selftests. I even have a patch ready to send for that, as I've
been struggling with selftests in the past days because some PHYs will
either stop their RXC while in loopback, or bring the carrier down which
makes the dev_xmit drop the packets we're sending to ourselves.

Using an external loopnback (in PCS, in PHY, somewhere else...) doesn't
bring anything to the table given what we are testing today, which is
internal stmmac behaviour. The MAC loopback (on dwmac1000 and dwmac4 at
least) happends at the GMII level, so everything we are currently testing
happens before that.

If the goal is to validate what comes after (RGMII, PCS behaviour and so on),
I think we should instead add some other, more generic selftests that aren't
stmmac specific, that we could run on any netdev, such as the ones Oleksij
has added in:

3e1e58d64c3d net: add generic selftest support

Maxime