cb9c411cfb0d35e2197a7170cb0c65faaa3d30cb
[openwrt/staging/neocturne.git] /
1 From 471c40bde606ec0b1ce8c616f7998739c7a783a6 Mon Sep 17 00:00:00 2001
2 From: Ivan Bornyakov <i.bornyakov@metrotek.ru>
3 Date: Fri, 10 Feb 2023 18:46:27 +0300
4 Subject: [PATCH 10/21] net: phylink: support validated pause and autoneg in
5 fixed-link
6
7 In fixed-link setup phylink_parse_fixedlink() unconditionally sets
8 Pause, Asym_Pause and Autoneg bits to "supported" bitmap, while MAC may
9 not support these.
10
11 This leads to ethtool reporting:
12
13 > Supported pause frame use: Symmetric Receive-only
14 > Supports auto-negotiation: Yes
15
16 regardless of what is actually supported.
17
18 Instead of unconditionally set Pause, Asym_Pause and Autoneg it is
19 sensible to set them according to validated "supported" bitmap, i.e. the
20 result of phylink_validate().
21
22 Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
23 Signed-off-by: David S. Miller <davem@davemloft.net>
24 ---
25 drivers/net/phy/phylink.c | 17 ++++++++++++++---
26 1 file changed, 14 insertions(+), 3 deletions(-)
27
28 --- a/drivers/net/phy/phylink.c
29 +++ b/drivers/net/phy/phylink.c
30 @@ -709,6 +709,7 @@ static int phylink_parse_fixedlink(struc
31 struct fwnode_handle *fwnode)
32 {
33 struct fwnode_handle *fixed_node;
34 + bool pause, asym_pause, autoneg;
35 const struct phy_setting *s;
36 struct gpio_desc *desc;
37 u32 speed;
38 @@ -781,13 +782,23 @@ static int phylink_parse_fixedlink(struc
39 linkmode_copy(pl->link_config.advertising, pl->supported);
40 phylink_validate(pl, pl->supported, &pl->link_config);
41
42 + pause = phylink_test(pl->supported, Pause);
43 + asym_pause = phylink_test(pl->supported, Asym_Pause);
44 + autoneg = phylink_test(pl->supported, Autoneg);
45 s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex,
46 pl->supported, true);
47 linkmode_zero(pl->supported);
48 phylink_set(pl->supported, MII);
49 - phylink_set(pl->supported, Pause);
50 - phylink_set(pl->supported, Asym_Pause);
51 - phylink_set(pl->supported, Autoneg);
52 +
53 + if (pause)
54 + phylink_set(pl->supported, Pause);
55 +
56 + if (asym_pause)
57 + phylink_set(pl->supported, Asym_Pause);
58 +
59 + if (autoneg)
60 + phylink_set(pl->supported, Autoneg);
61 +
62 if (s) {
63 __set_bit(s->bit, pl->supported);
64 __set_bit(s->bit, pl->link_config.lp_advertising);