Re: [PATCH net-next v1 7/7] net: usb: lan78xx: Enable EEE support with phylink integration

Oleksij Rempel
2025-01-18T07:22:48Z

On Fri, Jan 17, 2025 at 04:23:52PM +0000, Russell King (Oracle) wrote:
> I'm unsure about many DSA drivers. mt753x:
>
> u32 set, mask = LPI_THRESH_MASK | LPI_MODE_EN;
>
> if (e->tx_lpi_timer > 0xFFF)
> return -EINVAL;
>
> set = LPI_THRESH_SET(e->tx_lpi_timer);
> if (!e->tx_lpi_enabled)
> /* Force LPI Mode without a delay */
> set |= LPI_MODE_EN;
> mt7530_rmw(priv, MT753X_PMEEECR_P(port), mask, set);
>
> Why force LPI *without* a delay if tx_lpi_enabled is false? This
> seems to go against the documented API:
>
> * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
> * that eee was negotiated.

According to MT7531 manual, I would say, the code is not correct:
https://repo.librerouter.org/misc/lr2/MT7531_switch_Reference_Manual_for_Development_Board.pdf

The LPI_MODE_EN_Px bit has following meaning:

When there is no packet to be transmitted, and the idle time is greater
than P2_LPI_THRESHOLD, the TXMAC will automatically enter LPI (Low
Power Idle) mode and send EEE LPI frame to the link partner.
0: LPI mode depends on the P2_LPI_THRESHOLD.
1: Let the system enter the LPI mode immediately and send EEE LPI frame
to the link partner.

This chip seems to not have support for tx_lpi_enabled != eee_enabled
configuration.

> qca8k_set_mac_eee() sets the LPI enabled based off eee->eee_enabled.
> It doesn't seem to change the register on link up/down, so I wonder
> how the autoneg resolution is handled. Maybe it isn't, so maybe it's
> buggy.

The QCA8K_REG_EEE_CTRL_LPI_EN() bit is supported only for ports with
integrated PHYs. There seems to be no validation for this case.
Other problem with the code, lpi_en bit can be removed only one time.
Executing tx_lpi off and tx_lpi on in a sequence will not work.

My chip documentation do not provide any information about LPI_EN bit
functionality. I can't say for sure how it works.

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |