1 From febf2aaf05641f3258cc30e072aff65cffc7c82c Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 16 Jun 2023 13:06:32 +0100
4 Subject: [PATCH 2/2] net: phylink: pass neg_mode into
5 phylink_mii_c22_pcs_config()
7 Convert fman_dtsec, xilinx_axienet and pcs-lynx to pass the neg_mode
8 into phylink_mii_c22_pcs_config(). Where appropriate, drivers are
9 updated to have neg_mode passed into their pcs_config() and
10 pcs_link_up() functions. For other drivers, we just hoist the call
11 to phylink_pcs_neg_mode() to their pcs_config() method out of
12 phylink_mii_c22_pcs_config().
14 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
15 Link: https://lore.kernel.org/r/E1qA8Do-00EaFM-Ra@rmk-PC.armlinux.org.uk
16 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
18 .../net/ethernet/freescale/fman/fman_dtsec.c | 7 ++++---
19 .../net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++++--
20 drivers/net/pcs/pcs-lynx.c | 18 ++++++++++++------
21 drivers/net/phy/phylink.c | 9 ++++-----
22 include/linux/phylink.h | 5 +++--
23 5 files changed, 27 insertions(+), 18 deletions(-)
25 --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
26 +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
27 @@ -763,15 +763,15 @@ static void dtsec_pcs_get_state(struct p
28 phylink_mii_c22_pcs_get_state(dtsec->tbidev, state);
31 -static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
32 +static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
33 phy_interface_t interface,
34 const unsigned long *advertising,
35 bool permit_pause_to_mac)
37 struct fman_mac *dtsec = pcs_to_dtsec(pcs);
39 - return phylink_mii_c22_pcs_config(dtsec->tbidev, mode, interface,
41 + return phylink_mii_c22_pcs_config(dtsec->tbidev, interface,
42 + advertising, neg_mode);
45 static void dtsec_pcs_an_restart(struct phylink_pcs *pcs)
46 @@ -1447,6 +1447,7 @@ int dtsec_initialization(struct mac_devi
47 goto _return_fm_mac_free;
49 dtsec->pcs.ops = &dtsec_pcs_ops;
50 + dtsec->pcs.neg_mode = true;
51 dtsec->pcs.poll = true;
53 supported = mac_dev->phylink_config.supported_interfaces;
54 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
55 +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
56 @@ -1632,7 +1632,7 @@ static void axienet_pcs_an_restart(struc
57 phylink_mii_c22_pcs_an_restart(pcs_phy);
60 -static int axienet_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
61 +static int axienet_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
62 phy_interface_t interface,
63 const unsigned long *advertising,
64 bool permit_pause_to_mac)
65 @@ -1654,7 +1654,8 @@ static int axienet_pcs_config(struct phy
69 - ret = phylink_mii_c22_pcs_config(pcs_phy, mode, interface, advertising);
70 + ret = phylink_mii_c22_pcs_config(pcs_phy, interface, advertising,
73 netdev_warn(ndev, "Failed to configure PCS: %d\n", ret);
75 @@ -2130,6 +2131,7 @@ static int axienet_probe(struct platform
78 lp->pcs.ops = &axienet_pcs_ops;
79 + lp->pcs.neg_mode = true;
83 --- a/drivers/net/pcs/pcs-lynx.c
84 +++ b/drivers/net/pcs/pcs-lynx.c
85 @@ -122,9 +122,10 @@ static void lynx_pcs_get_state(struct ph
86 state->link, state->an_complete);
89 -static int lynx_pcs_config_giga(struct mdio_device *pcs, unsigned int mode,
90 +static int lynx_pcs_config_giga(struct mdio_device *pcs,
91 phy_interface_t interface,
92 - const unsigned long *advertising)
93 + const unsigned long *advertising,
94 + unsigned int neg_mode)
98 @@ -137,8 +138,9 @@ static int lynx_pcs_config_giga(struct m
102 + /* SGMII and QSGMII */
103 if_mode = IF_MODE_SGMII_EN;
104 - if (mode == MLO_AN_INBAND) {
105 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
106 if_mode |= IF_MODE_USE_SGMII_AN;
108 /* Adjust link timer for SGMII */
109 @@ -154,7 +156,8 @@ static int lynx_pcs_config_giga(struct m
113 - return phylink_mii_c22_pcs_config(pcs, mode, interface, advertising);
114 + return phylink_mii_c22_pcs_config(pcs, interface, advertising,
118 static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, unsigned int mode,
119 @@ -181,13 +184,16 @@ static int lynx_pcs_config(struct phylin
122 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs);
123 + unsigned int neg_mode;
125 + neg_mode = phylink_pcs_neg_mode(mode, ifmode, advertising);
128 case PHY_INTERFACE_MODE_1000BASEX:
129 case PHY_INTERFACE_MODE_SGMII:
130 case PHY_INTERFACE_MODE_QSGMII:
131 - return lynx_pcs_config_giga(lynx->mdio, mode, ifmode,
133 + return lynx_pcs_config_giga(lynx->mdio, ifmode, advertising,
135 case PHY_INTERFACE_MODE_2500BASEX:
136 if (phylink_autoneg_inband(mode)) {
137 dev_err(&lynx->mdio->dev,
138 --- a/drivers/net/phy/phylink.c
139 +++ b/drivers/net/phy/phylink.c
140 @@ -3545,20 +3545,20 @@ EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_en
142 * phylink_mii_c22_pcs_config() - configure clause 22 PCS
143 * @pcs: a pointer to a &struct mdio_device.
144 - * @mode: link autonegotiation mode
145 * @interface: the PHY interface mode being configured
146 * @advertising: the ethtool advertisement mask
147 + * @neg_mode: PCS negotiation mode
149 * Configure a Clause 22 PCS PHY with the appropriate negotiation
150 * parameters for the @mode, @interface and @advertising parameters.
151 * Returns negative error number on failure, zero if the advertisement
152 * has not changed, or positive if there is a change.
154 -int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode,
155 +int phylink_mii_c22_pcs_config(struct mdio_device *pcs,
156 phy_interface_t interface,
157 - const unsigned long *advertising)
158 + const unsigned long *advertising,
159 + unsigned int neg_mode)
161 - unsigned int neg_mode;
165 @@ -3572,7 +3572,6 @@ int phylink_mii_c22_pcs_config(struct md
169 - neg_mode = phylink_pcs_neg_mode(mode, interface, advertising);
170 if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)
171 bmcr = BMCR_ANENABLE;
173 --- a/include/linux/phylink.h
174 +++ b/include/linux/phylink.h
175 @@ -743,9 +743,10 @@ void phylink_mii_c22_pcs_get_state(struc
176 struct phylink_link_state *state);
177 int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface,
178 const unsigned long *advertising);
179 -int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode,
180 +int phylink_mii_c22_pcs_config(struct mdio_device *pcs,
181 phy_interface_t interface,
182 - const unsigned long *advertising);
183 + const unsigned long *advertising,
184 + unsigned int neg_mode);
185 void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
187 void phylink_resolve_c73(struct phylink_link_state *state);