mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0380-net-phylink-add-support-for-polling-MAC-PCS.patch
1 From c12db737cf62ca262c01ec6d4ba942b34db35d8b Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Fri, 27 Dec 2019 19:45:22 +0200
4 Subject: [PATCH] net: phylink: add support for polling MAC PCS
5
6 Some MAC PCS blocks are unable to provide interrupts when their status
7 changes. As we already have support in phylink for polling status, use
8 this to provide a hook for MACs to enable polling mode.
9
10 The patch idea was picked up from Russell King's suggestion on the macb
11 phylink patch thread here [0] but the implementation was changed.
12 Instead of introducing a new phylink_start_poll() function, which would
13 make the implementation cumbersome for common PHYLINK implementations
14 for multiple types of devices, like DSA, just add a boolean property to
15 the phylink_config structure, which is just as backwards-compatible.
16
17 https://lkml.org/lkml/2019/12/16/603
18
19 Suggested-by: Russell King <rmk+kernel@armlinux.org.uk>
20 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
21 [rebase]
22 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
23
24 Conflicts:
25 drivers/net/phy/phylink.c
26
27 with upstream commit 24cf0e693bb5 ("net: phylink: split link_an_mode
28 configured and current settings") submitted for net-next and merged
29 during v5.5-rc1.
30 ---
31 Documentation/networking/sfp-phylink.rst | 3 ++-
32 drivers/net/phy/phylink.c | 3 ++-
33 include/linux/phylink.h | 2 ++
34 3 files changed, 6 insertions(+), 2 deletions(-)
35
36 --- a/Documentation/networking/sfp-phylink.rst
37 +++ b/Documentation/networking/sfp-phylink.rst
38 @@ -251,7 +251,8 @@ this documentation.
39 phylink_mac_change(priv->phylink, link_is_up);
40
41 where ``link_is_up`` is true if the link is currently up or false
42 - otherwise.
43 + otherwise. If a MAC is unable to provide these interrupts, then
44 + it should set ``priv->phylink_config.pcs_poll = true;`` in step 9.
45
46 11. Verify that the driver does not call::
47
48 --- a/drivers/net/phy/phylink.c
49 +++ b/drivers/net/phy/phylink.c
50 @@ -1008,7 +1008,8 @@ void phylink_start(struct phylink *pl)
51 if (irq <= 0)
52 mod_timer(&pl->link_poll, jiffies + HZ);
53 }
54 - if (pl->cfg_link_an_mode == MLO_AN_FIXED && pl->get_fixed_state)
55 + if ((pl->cfg_link_an_mode == MLO_AN_FIXED && pl->get_fixed_state) ||
56 + pl->config->pcs_poll)
57 mod_timer(&pl->link_poll, jiffies + HZ);
58 if (pl->phydev)
59 phy_start(pl->phydev);
60 --- a/include/linux/phylink.h
61 +++ b/include/linux/phylink.h
62 @@ -63,10 +63,12 @@ enum phylink_op_type {
63 * struct phylink_config - PHYLINK configuration structure
64 * @dev: a pointer to a struct device associated with the MAC
65 * @type: operation type of PHYLINK instance
66 + * @pcs_poll: MAC PCS cannot provide link change interrupt
67 */
68 struct phylink_config {
69 struct device *dev;
70 enum phylink_op_type type;
71 + bool pcs_poll;
72 };
73
74 /**