kernel: bump 5.4 to 5.4.90
[openwrt/openwrt.git] / target / linux / mediatek / patches-5.4 / 0600-net-phylink-propagate-resolved-link-config-via-mac_l.patch
1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Wed, 26 Feb 2020 10:23:41 +0000
3 Subject: [PATCH] net: phylink: propagate resolved link config via
4 mac_link_up()
5
6 Propagate the resolved link parameters via the mac_link_up() call for
7 MACs that do not automatically track their PCS state. We propagate the
8 link parameters via function arguments so that inappropriate members
9 of struct phylink_link_state can't be accessed, and creating a new
10 structure just for this adds needless complexity to the API.
11
12 Tested-by: Andre Przywara <andre.przywara@arm.com>
13 Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
14 Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
15 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18
19 --- a/Documentation/networking/sfp-phylink.rst
20 +++ b/Documentation/networking/sfp-phylink.rst
21 @@ -74,10 +74,13 @@ phylib to the sfp/phylink support. Plea
22 this documentation.
23
24 1. Optionally split the network driver's phylib update function into
25 - three parts dealing with link-down, link-up and reconfiguring the
26 - MAC settings. This can be done as a separate preparation commit.
27 + two parts dealing with link-down and link-up. This can be done as
28 + a separate preparation commit.
29
30 - An example of this preparation can be found in git commit fc548b991fb0.
31 + An older example of this preparation can be found in git commit
32 + fc548b991fb0, although this was splitting into three parts; the
33 + link-up part now includes configuring the MAC for the link settings.
34 + Please see :c:func:`mac_link_up` for more information on this.
35
36 2. Replace::
37
38 @@ -207,6 +210,14 @@ this documentation.
39 using. This is particularly important for in-band negotiation
40 methods such as 1000base-X and SGMII.
41
42 + The :c:func:`mac_link_up` method is used to inform the MAC that the
43 + link has come up. The call includes the negotiation mode and interface
44 + for reference only. The finalised link parameters are also supplied
45 + (speed, duplex and flow control/pause enablement settings) which
46 + should be used to configure the MAC when the MAC and PCS are not
47 + tightly integrated, or when the settings are not coming from in-band
48 + negotiation.
49 +
50 The :c:func:`mac_config` method is used to update the MAC with the
51 requested state, and must avoid unnecessarily taking the link down
52 when making changes to the MAC configuration. This means the
53 --- a/drivers/net/ethernet/marvell/mvneta.c
54 +++ b/drivers/net/ethernet/marvell/mvneta.c
55 @@ -3653,9 +3653,11 @@ static void mvneta_mac_link_down(struct
56 mvneta_set_eee(pp, false);
57 }
58
59 -static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
60 - phy_interface_t interface,
61 - struct phy_device *phy)
62 +static void mvneta_mac_link_up(struct phylink_config *config,
63 + struct phy_device *phy,
64 + unsigned int mode, phy_interface_t interface,
65 + int speed, int duplex,
66 + bool tx_pause, bool rx_pause)
67 {
68 struct net_device *ndev = to_net_dev(config->dev);
69 struct mvneta_port *pp = netdev_priv(ndev);
70 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
71 +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
72 @@ -58,8 +58,11 @@ static struct {
73 */
74 static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
75 const struct phylink_link_state *state);
76 -static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
77 - phy_interface_t interface, struct phy_device *phy);
78 +static void mvpp2_mac_link_up(struct phylink_config *config,
79 + struct phy_device *phy,
80 + unsigned int mode, phy_interface_t interface,
81 + int speed, int duplex,
82 + bool tx_pause, bool rx_pause);
83
84 /* Queue modes */
85 #define MVPP2_QDIST_SINGLE_MODE 0
86 @@ -3468,8 +3471,9 @@ static void mvpp2_start_dev(struct mvpp2
87 .interface = port->phy_interface,
88 };
89 mvpp2_mac_config(&port->phylink_config, MLO_AN_INBAND, &state);
90 - mvpp2_mac_link_up(&port->phylink_config, MLO_AN_INBAND,
91 - port->phy_interface, NULL);
92 + mvpp2_mac_link_up(&port->phylink_config, NULL,
93 + MLO_AN_INBAND, port->phy_interface,
94 + SPEED_UNKNOWN, DUPLEX_UNKNOWN, false, false);
95 }
96
97 netif_tx_start_all_queues(port->dev);
98 @@ -5139,8 +5143,11 @@ static void mvpp2_mac_config(struct phyl
99 mvpp2_port_enable(port);
100 }
101
102 -static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
103 - phy_interface_t interface, struct phy_device *phy)
104 +static void mvpp2_mac_link_up(struct phylink_config *config,
105 + struct phy_device *phy,
106 + unsigned int mode, phy_interface_t interface,
107 + int speed, int duplex,
108 + bool tx_pause, bool rx_pause)
109 {
110 struct mvpp2_port *port = mvpp2_phylink_to_port(config);
111 u32 val;
112 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
113 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
114 @@ -449,9 +449,10 @@ static void mtk_mac_link_down(struct phy
115 mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
116 }
117
118 -static void mtk_mac_link_up(struct phylink_config *config, unsigned int mode,
119 - phy_interface_t interface,
120 - struct phy_device *phy)
121 +static void mtk_mac_link_up(struct phylink_config *config,
122 + struct phy_device *phy,
123 + unsigned int mode, phy_interface_t interface,
124 + int speed, int duplex, bool tx_pause, bool rx_pause)
125 {
126 struct mtk_mac *mac = container_of(config, struct mtk_mac,
127 phylink_config);
128 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
129 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
130 @@ -925,8 +925,10 @@ static void stmmac_mac_link_down(struct
131 }
132
133 static void stmmac_mac_link_up(struct phylink_config *config,
134 + struct phy_device *phy,
135 unsigned int mode, phy_interface_t interface,
136 - struct phy_device *phy)
137 + int speed, int duplex,
138 + bool tx_pause, bool rx_pause)
139 {
140 struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
141
142 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
143 +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
144 @@ -1499,9 +1499,10 @@ static void axienet_mac_link_down(struct
145 }
146
147 static void axienet_mac_link_up(struct phylink_config *config,
148 - unsigned int mode,
149 - phy_interface_t interface,
150 - struct phy_device *phy)
151 + struct phy_device *phy,
152 + unsigned int mode, phy_interface_t interface,
153 + int speed, int duplex,
154 + bool tx_pause, bool rx_pause)
155 {
156 /* nothing meaningful to do */
157 }
158 --- a/drivers/net/phy/phylink.c
159 +++ b/drivers/net/phy/phylink.c
160 @@ -447,8 +447,11 @@ static void phylink_mac_link_up(struct p
161 struct net_device *ndev = pl->netdev;
162
163 pl->cur_interface = link_state.interface;
164 - pl->ops->mac_link_up(pl->config, pl->cur_link_an_mode,
165 - pl->cur_interface, pl->phydev);
166 + pl->ops->mac_link_up(pl->config, pl->phydev,
167 + pl->cur_link_an_mode, pl->cur_interface,
168 + link_state.speed, link_state.duplex,
169 + !!(link_state.pause & MLO_PAUSE_TX),
170 + !!(link_state.pause & MLO_PAUSE_RX));
171
172 if (ndev)
173 netif_carrier_on(ndev);
174 --- a/include/linux/phylink.h
175 +++ b/include/linux/phylink.h
176 @@ -91,9 +91,10 @@ struct phylink_mac_ops {
177 void (*mac_an_restart)(struct phylink_config *config);
178 void (*mac_link_down)(struct phylink_config *config, unsigned int mode,
179 phy_interface_t interface);
180 - void (*mac_link_up)(struct phylink_config *config, unsigned int mode,
181 - phy_interface_t interface,
182 - struct phy_device *phy);
183 + void (*mac_link_up)(struct phylink_config *config,
184 + struct phy_device *phy, unsigned int mode,
185 + phy_interface_t interface, int speed, int duplex,
186 + bool tx_pause, bool rx_pause);
187 };
188
189 #if 0 /* For kernel-doc purposes only. */
190 @@ -217,19 +218,34 @@ void mac_link_down(struct phylink_config
191 /**
192 * mac_link_up() - allow the link to come up
193 * @config: a pointer to a &struct phylink_config.
194 + * @phy: any attached phy
195 * @mode: link autonegotiation mode
196 * @interface: link &typedef phy_interface_t mode
197 - * @phy: any attached phy
198 + * @speed: link speed
199 + * @duplex: link duplex
200 + * @tx_pause: link transmit pause enablement status
201 + * @rx_pause: link receive pause enablement status
202 + *
203 + * Configure the MAC for an established link.
204 + *
205 + * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link
206 + * settings, and should be used to configure the MAC block appropriately
207 + * where these settings are not automatically conveyed from the PCS block,
208 + * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode))
209 + * is disabled.
210 + *
211 + * Note that when 802.3z in-band negotiation is in use, it is possible
212 + * that the user wishes to override the pause settings, and this should
213 + * be allowed when considering the implementation of this method.
214 *
215 - * If @mode is not an in-band negotiation mode (as defined by
216 - * phylink_autoneg_inband()), allow the link to come up. If @phy
217 - * is non-%NULL, configure Energy Efficient Ethernet by calling
218 + * If in-band negotiation mode is disabled, allow the link to come up. If
219 + * @phy is non-%NULL, configure Energy Efficient Ethernet by calling
220 * phy_init_eee() and perform appropriate MAC configuration for EEE.
221 * Interface type selection must be done in mac_config().
222 */
223 -void mac_link_up(struct phylink_config *config, unsigned int mode,
224 - phy_interface_t interface,
225 - struct phy_device *phy);
226 +void mac_link_up(struct phylink_config *config, struct phy_device *phy,
227 + unsigned int mode, phy_interface_t interface,
228 + int speed, int duplex, bool tx_pause, bool rx_pause);
229 #endif
230
231 struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
232 --- a/net/dsa/port.c
233 +++ b/net/dsa/port.c
234 @@ -529,9 +529,11 @@ void dsa_port_phylink_mac_link_down(stru
235 EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_down);
236
237 void dsa_port_phylink_mac_link_up(struct phylink_config *config,
238 + struct phy_device *phydev,
239 unsigned int mode,
240 phy_interface_t interface,
241 - struct phy_device *phydev)
242 + int speed, int duplex,
243 + bool tx_pause, bool rx_pause)
244 {
245 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
246 struct dsa_switch *ds = dp->ds;