net: phylink: support validated pause and autoneg in fixed-link
authorIvan Bornyakov <i.bornyakov@metrotek.ru>
Fri, 10 Feb 2023 15:46:27 +0000 (18:46 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Feb 2023 10:35:27 +0000 (10:35 +0000)
In fixed-link setup phylink_parse_fixedlink() unconditionally sets
Pause, Asym_Pause and Autoneg bits to "supported" bitmap, while MAC may
not support these.

This leads to ethtool reporting:

 > Supported pause frame use: Symmetric Receive-only
 > Supports auto-negotiation: Yes

regardless of what is actually supported.

Instead of unconditionally set Pause, Asym_Pause and Autoneg it is
sensible to set them according to validated "supported" bitmap, i.e. the
result of phylink_validate().

Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phylink.c

index ea8fcce5b2d96d28454136d905b9e1ea68d74ad0..1a2f074685fa9f386f30b87a5b3fe750009b8696 100644 (file)
@@ -711,6 +711,7 @@ static int phylink_parse_fixedlink(struct phylink *pl,
                                   struct fwnode_handle *fwnode)
 {
        struct fwnode_handle *fixed_node;
+       bool pause, asym_pause, autoneg;
        const struct phy_setting *s;
        struct gpio_desc *desc;
        u32 speed;
@@ -783,13 +784,23 @@ static int phylink_parse_fixedlink(struct phylink *pl,
        linkmode_copy(pl->link_config.advertising, pl->supported);
        phylink_validate(pl, pl->supported, &pl->link_config);
 
+       pause = phylink_test(pl->supported, Pause);
+       asym_pause = phylink_test(pl->supported, Asym_Pause);
+       autoneg = phylink_test(pl->supported, Autoneg);
        s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex,
                               pl->supported, true);
        linkmode_zero(pl->supported);
        phylink_set(pl->supported, MII);
-       phylink_set(pl->supported, Pause);
-       phylink_set(pl->supported, Asym_Pause);
-       phylink_set(pl->supported, Autoneg);
+
+       if (pause)
+               phylink_set(pl->supported, Pause);
+
+       if (asym_pause)
+               phylink_set(pl->supported, Asym_Pause);
+
+       if (autoneg)
+               phylink_set(pl->supported, Autoneg);
+
        if (s) {
                __set_bit(s->bit, pl->supported);
                __set_bit(s->bit, pl->link_config.lp_advertising);