Subject: Re: [PATCH net v2] net: phy: dp83869: fix status reporting for 1000base-x autonegotiation

From: "Russell King (Oracle)" <[email-masked]>
Date: Thu, 7 Nov 2024 17:36:30 +0000

On Mon, Nov 04, 2024 at 09:52:32AM +0100, Romain Gantois wrote:
> The DP83869 PHY transceiver supports converting from RGMII to 1000base-x.
> In this operation mode, autonegotiation can be performed, as described in
> IEEE802.3.
> 
> The DP83869 has a set of fiber-specific registers located at offset 0xc00.
> When the transceiver is configured in RGMII-to-1000base-x mode, these
> registers are mapped onto offset 0, which should, in theory, make reading
> the autonegotiation status transparent.
> 
> However, the fiber registers at offset 0xc04 and 0xc05 do not follow the
> bit layout of their standard counterparts. Thus, genphy_read_status()
> doesn't properly read the capabilities advertised by the link partner,
> resulting in incorrect link parameters.

This description is wrong. The format of registers 4 and 5 depends on
the media.

In twisted-pair ethernet, then:

ADVERTISE_PAUSE_ASYM / LPA_PAUSE_ASYM
ADVERTISE_PAUSE_CAP / LPA_PAUSE_CAP
ADVERTISE_100FULL / LPA_100FULL
ADVERTISE_100HALF / LPA_100HALF
ADVERTISE_10FULL / LPA_10FULL
ADVERTISE_10HALF / LPA_10HALF
ADVERTISE_CSMA

apply. In 1000base-X:

ADVERTISE_1000XPSE_ASYM / LPA_1000XPAUSE_ASYM
ADVERTISE_1000XPAUSE / LPA_1000XPAUSE
ADVERTISE_1000XHALF / LPA_1000XHALF
ADVERTISE_1000XFULL / LPA_1000XFULL

apply - these being bits 8, 7, 6, 5:

> +#define DP83869_LPA_1000FULL   BIT(5)
> +#define DP83869_LPA_PAUSE_CAP  BIT(7)
> +#define DP83869_LPA_PAUSE_ASYM BIT(8)
> +#define DP83869_LPA_LPACK      BIT(14)

so these are just reimplementing definitions we already have. Please
use the existing definitions. Even better, use mii_lpa_mod_linkmode_x()
and linkmode_adv_to_mii_adv_x() which we already have in your code.

Same likely goes for DP83869_BP_*

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!