8158c78b0ea4062e2666cc7dfffcdb21971fe89a
[openwrt/openwrt.git] / target / linux / generic / pending-5.4 / 741-net-sfp-derive-interface-mode-from-ethtool-link-mode.patch
1 From dc45d9e04572b5cd6d32f51cdf9f62b18022e6dd Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Thu, 21 Nov 2019 17:32:59 +0000
4 Subject: [PATCH 644/660] net: sfp: derive interface mode from ethtool link
5 modes
6
7 We don't need the EEPROM ID to derive the phy interface mode as we can
8 derive it merely from the ethtool link modes. Remove the EEPROM ID
9 argument to sfp_select_interface().
10
11 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
12 ---
13 drivers/net/phy/marvell10g.c | 2 +-
14 drivers/net/phy/phylink.c | 2 +-
15 drivers/net/phy/sfp-bus.c | 11 ++++-------
16 include/linux/sfp.h | 2 --
17 4 files changed, 6 insertions(+), 11 deletions(-)
18
19 --- a/drivers/net/phy/marvell10g.c
20 +++ b/drivers/net/phy/marvell10g.c
21 @@ -214,7 +214,7 @@ static int mv3310_sfp_insert(void *upstr
22 phy_interface_t iface;
23
24 sfp_parse_support(phydev->sfp_bus, id, support);
25 - iface = sfp_select_interface(phydev->sfp_bus, id, support);
26 + iface = sfp_select_interface(phydev->sfp_bus, support);
27
28 if (iface != PHY_INTERFACE_MODE_10GKR) {
29 dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
30 --- a/drivers/net/phy/phylink.c
31 +++ b/drivers/net/phy/phylink.c
32 @@ -1718,7 +1718,7 @@ static int phylink_sfp_module_insert(voi
33
34 linkmode_copy(support1, support);
35
36 - iface = sfp_select_interface(pl->sfp_bus, id, config.advertising);
37 + iface = sfp_select_interface(pl->sfp_bus, config.advertising);
38 if (iface == PHY_INTERFACE_MODE_NA) {
39 phylink_err(pl,
40 "selection of interface failed, advertisement %*pb\n",
41 --- a/drivers/net/phy/sfp-bus.c
42 +++ b/drivers/net/phy/sfp-bus.c
43 @@ -320,16 +320,12 @@ EXPORT_SYMBOL_GPL(sfp_parse_support);
44 /**
45 * sfp_select_interface() - Select appropriate phy_interface_t mode
46 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
47 - * @id: a pointer to the module's &struct sfp_eeprom_id
48 * @link_modes: ethtool link modes mask
49 *
50 - * Derive the phy_interface_t mode for the information found in the
51 - * module's identifying EEPROM and the link modes mask. There is no
52 - * standard or defined way to derive this information, so we decide
53 - * based upon the link mode mask.
54 + * Derive the phy_interface_t mode for the SFP module from the link
55 + * modes mask.
56 */
57 phy_interface_t sfp_select_interface(struct sfp_bus *bus,
58 - const struct sfp_eeprom_id *id,
59 unsigned long *link_modes)
60 {
61 if (phylink_test(link_modes, 10000baseCR_Full) ||
62 @@ -342,7 +338,8 @@ phy_interface_t sfp_select_interface(str
63 if (phylink_test(link_modes, 2500baseX_Full))
64 return PHY_INTERFACE_MODE_2500BASEX;
65
66 - if (id->base.e1000_base_t)
67 + if (phylink_test(link_modes, 1000baseT_Half) ||
68 + phylink_test(link_modes, 1000baseT_Full))
69 return PHY_INTERFACE_MODE_SGMII;
70
71 if (phylink_test(link_modes, 1000baseX_Full))
72 --- a/include/linux/sfp.h
73 +++ b/include/linux/sfp.h
74 @@ -504,7 +504,6 @@ int sfp_parse_port(struct sfp_bus *bus,
75 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
76 unsigned long *support);
77 phy_interface_t sfp_select_interface(struct sfp_bus *bus,
78 - const struct sfp_eeprom_id *id,
79 unsigned long *link_modes);
80
81 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo);
82 @@ -532,7 +531,6 @@ static inline void sfp_parse_support(str
83 }
84
85 static inline phy_interface_t sfp_select_interface(struct sfp_bus *bus,
86 - const struct sfp_eeprom_id *id,
87 unsigned long *link_modes)
88 {
89 return PHY_INTERFACE_MODE_NA;