kernel: bump 4.14 to 4.14.112
[openwrt/openwrt.git] / target / linux / mvebu / patches-4.14 / 408-sfp-move-module-eeprom-ethtool-access-into-netdev-co.patch
1 From c47beb7e3f8575dfd7d58240a72c4e4e66ce5449 Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 14 Apr 2017 15:26:32 +0100
4 Subject: sfp: move module eeprom ethtool access into netdev core ethtool
5
6 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
7 ---
8 drivers/net/ethernet/marvell/mvneta.c | 18 ------------------
9 drivers/net/phy/phylink.c | 28 ----------------------------
10 drivers/net/phy/sfp-bus.c | 6 ++----
11 include/linux/netdevice.h | 2 ++
12 include/linux/phylink.h | 3 ---
13 net/core/ethtool.c | 7 +++++++
14 6 files changed, 11 insertions(+), 53 deletions(-)
15
16 --- a/drivers/net/ethernet/marvell/mvneta.c
17 +++ b/drivers/net/ethernet/marvell/mvneta.c
18 @@ -4045,22 +4045,6 @@ static int mvneta_ethtool_set_wol(struct
19 return ret;
20 }
21
22 -static int mvneta_ethtool_get_module_info(struct net_device *dev,
23 - struct ethtool_modinfo *modinfo)
24 -{
25 - struct mvneta_port *pp = netdev_priv(dev);
26 -
27 - return phylink_ethtool_get_module_info(pp->phylink, modinfo);
28 -}
29 -
30 -static int mvneta_ethtool_get_module_eeprom(struct net_device *dev,
31 - struct ethtool_eeprom *ee, u8 *buf)
32 -{
33 - struct mvneta_port *pp = netdev_priv(dev);
34 -
35 - return phylink_ethtool_get_module_eeprom(pp->phylink, ee, buf);
36 -}
37 -
38 static int mvneta_ethtool_get_eee(struct net_device *dev,
39 struct ethtool_eee *eee)
40 {
41 @@ -4145,8 +4129,6 @@ static const struct ethtool_ops mvneta_e
42 .set_link_ksettings = mvneta_ethtool_set_link_ksettings,
43 .get_wol = mvneta_ethtool_get_wol,
44 .set_wol = mvneta_ethtool_set_wol,
45 - .get_module_info = mvneta_ethtool_get_module_info,
46 - .get_module_eeprom = mvneta_ethtool_get_module_eeprom,
47 .get_eee = mvneta_ethtool_get_eee,
48 .set_eee = mvneta_ethtool_set_eee,
49 };
50 --- a/drivers/net/phy/phylink.c
51 +++ b/drivers/net/phy/phylink.c
52 @@ -1058,34 +1058,6 @@ int phylink_ethtool_set_pauseparam(struc
53 }
54 EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
55
56 -int phylink_ethtool_get_module_info(struct phylink *pl,
57 - struct ethtool_modinfo *modinfo)
58 -{
59 - int ret = -EOPNOTSUPP;
60 -
61 - WARN_ON(!lockdep_rtnl_is_held());
62 -
63 - if (pl->sfp_bus)
64 - ret = sfp_get_module_info(pl->sfp_bus, modinfo);
65 -
66 - return ret;
67 -}
68 -EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
69 -
70 -int phylink_ethtool_get_module_eeprom(struct phylink *pl,
71 - struct ethtool_eeprom *ee, u8 *buf)
72 -{
73 - int ret = -EOPNOTSUPP;
74 -
75 - WARN_ON(!lockdep_rtnl_is_held());
76 -
77 - if (pl->sfp_bus)
78 - ret = sfp_get_module_eeprom(pl->sfp_bus, ee, buf);
79 -
80 - return ret;
81 -}
82 -EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
83 -
84 int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
85 {
86 int ret = -EPROTONOSUPPORT;
87 --- a/drivers/net/phy/sfp-bus.c
88 +++ b/drivers/net/phy/sfp-bus.c
89 @@ -279,6 +279,7 @@ static int sfp_register_bus(struct sfp_b
90 bus->socket_ops->attach(bus->sfp);
91 if (bus->started)
92 bus->socket_ops->start(bus->sfp);
93 + bus->netdev->sfp_bus = bus;
94 bus->registered = true;
95 return 0;
96 }
97 @@ -294,14 +295,13 @@ static void sfp_unregister_bus(struct sf
98 if (bus->phydev && ops && ops->disconnect_phy)
99 ops->disconnect_phy(bus->upstream);
100 }
101 + bus->netdev->sfp_bus = NULL;
102 bus->registered = false;
103 }
104
105
106 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo)
107 {
108 - if (!bus->registered)
109 - return -ENOIOCTLCMD;
110 return bus->socket_ops->module_info(bus->sfp, modinfo);
111 }
112 EXPORT_SYMBOL_GPL(sfp_get_module_info);
113 @@ -309,8 +309,6 @@ EXPORT_SYMBOL_GPL(sfp_get_module_info);
114 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
115 u8 *data)
116 {
117 - if (!bus->registered)
118 - return -ENOIOCTLCMD;
119 return bus->socket_ops->module_eeprom(bus->sfp, ee, data);
120 }
121 EXPORT_SYMBOL_GPL(sfp_get_module_eeprom);
122 --- a/include/linux/netdevice.h
123 +++ b/include/linux/netdevice.h
124 @@ -57,6 +57,7 @@ struct device;
125 struct phy_device;
126 struct dsa_switch_tree;
127
128 +struct sfp_bus;
129 /* 802.11 specific */
130 struct wireless_dev;
131 /* 802.15.4 specific */
132 @@ -1935,6 +1936,7 @@ struct net_device {
133 struct netprio_map __rcu *priomap;
134 #endif
135 struct phy_device *phydev;
136 + struct sfp_bus *sfp_bus;
137 struct lock_class_key *qdisc_tx_busylock;
138 struct lock_class_key *qdisc_running_key;
139 bool proto_down;
140 --- a/include/linux/phylink.h
141 +++ b/include/linux/phylink.h
142 @@ -125,9 +125,6 @@ void phylink_ethtool_get_pauseparam(stru
143 struct ethtool_pauseparam *);
144 int phylink_ethtool_set_pauseparam(struct phylink *,
145 struct ethtool_pauseparam *);
146 -int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *);
147 -int phylink_ethtool_get_module_eeprom(struct phylink *,
148 - struct ethtool_eeprom *, u8 *);
149 int phylink_init_eee(struct phylink *, bool);
150 int phylink_get_eee_err(struct phylink *);
151 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
152 --- a/net/core/ethtool.c
153 +++ b/net/core/ethtool.c
154 @@ -22,6 +22,7 @@
155 #include <linux/bitops.h>
156 #include <linux/uaccess.h>
157 #include <linux/vmalloc.h>
158 +#include <linux/sfp.h>
159 #include <linux/slab.h>
160 #include <linux/rtnetlink.h>
161 #include <linux/sched/signal.h>
162 @@ -2201,6 +2202,9 @@ static int __ethtool_get_module_info(str
163 const struct ethtool_ops *ops = dev->ethtool_ops;
164 struct phy_device *phydev = dev->phydev;
165
166 + if (dev->sfp_bus)
167 + return sfp_get_module_info(dev->sfp_bus, modinfo);
168 +
169 if (phydev && phydev->drv && phydev->drv->module_info)
170 return phydev->drv->module_info(phydev, modinfo);
171
172 @@ -2235,6 +2239,9 @@ static int __ethtool_get_module_eeprom(s
173 const struct ethtool_ops *ops = dev->ethtool_ops;
174 struct phy_device *phydev = dev->phydev;
175
176 + if (dev->sfp_bus)
177 + return sfp_get_module_eeprom(dev->sfp_bus, ee, data);
178 +
179 if (phydev && phydev->drv && phydev->drv->module_eeprom)
180 return phydev->drv->module_eeprom(phydev, ee, data);
181