Subject: mvpp2 switch from gmac to xlg requires ifdown/ifup

From: Marek Behún <[email-masked]>
Date: Fri, 23 Jul 2021 03:52:02 +0200

Hello Russell (and possibly others),

I discovered that with mvpp2 when switching from gmac (sgmii or
2500base-x mode) to xlg (10gbase-r mode) due to phylink requesting this
change, the link won't come up unless I do
  ifconfig ethX down
  ifconfig ethX up

Can be reproduced on MacchiatoBIN:
1. connect the two 10g RJ-45 ports (88X3310 PHY) with one cable
2. bring the interfaces up
3. the PHYs should link in 10gbase-t, links on MACs will go up in
   10gbase-r
4. use ethtool on one of the interfaces to advertise modes only up to
   2500base-t
5. the PHYs will unlink and then link at 2.5gbase-t, links on MACs will
   go up in 2500base-x
6. use ethtool on the same interface as in step 4 to advertise all
   supported modes

7. the PHYs will unlink and then link at 10gbase-t, BUT MACs won't link
   !!!
8. execute
     ifconfig ethX down ; ifconfig ethX up
   on both interfaces. After this, the MACs will successfully link in
   10gbase-r with the PHYs

It seems that the mvpp2 driver code needs to make additional stuff when
chaning mode from gmac to xlg. I haven't yet been able to find out
what, though.

BTW I discovered this because I am working on adding support for
5gbase-r mode to mvpp2, so that the PHY can support 5gbase-t on copper
side.
The ifdown/ifup cycle is required when switching from gmac to xlg, i.e.:
	sgmii		to	5gbase-r
	sgmii		to	10gbase-r
	2500base-x	to	5gbase-r
	2500base-x	to	10gbase-r
but also when switching from xlg to different xlg:
	5gbase-r	to	10gbase-r
	10gbase-r	to	5gbase-r

Did someone notice this bug? I see that Russell made some changes in
the phylink pcs API that touched mvpp2 (the .mac_config method got
split into .mac_prepare, .mac_config and .mac_finish, and also some
other changes). I haven't tried yet if the switch from gmac to xlg
worked at some time in the past. But if it did, maybe these changes
could be the cause?

Marek