aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Greene <jogreene@redhat.com>2012-12-03 01:19:33 -0500
committerDavid S. Miller <davem@davemloft.net>2012-12-03 13:51:16 -0500
commitcb64edb6b89491edfdbae52ba7db9a8b8391d339 (patch)
tree17ee6f67794d8c68be8a1ae572812ab26f673108
parenteb0fb363f920e4d8c70d30b712f9dd433271218c (diff)
8139cp: properly support change of MTU values [v2]
The 8139cp driver has a change_mtu function that has not been enabled since the dawn of the git repository. However, the generic eth_change_mtu is not used in its place, so that invalid MTU values can be set on the interface. Original patch salvages the broken code for the single case of setting the MTU while the interface is down, which is safe and also includes the range check. Now enhanced to support up or down interface. v2: fix case where rxbufsz isn't changed in the up state case Original patch from http://lkml.indiana.edu/hypermail/linux/kernel/1202.2/00770.html Testing: has been test on virtual 8139cp setup without issue, have no access real hardware 8139cp, need testing help. Signed-off-by: "John Greene" <jogreene@redhat.com> CC: "David S. Miller" <davem@davemloft.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index 6cb96b4afdf5..0da3f5e9b1a5 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -1226,12 +1226,9 @@ static void cp_tx_timeout(struct net_device *dev)
1226 spin_unlock_irqrestore(&cp->lock, flags); 1226 spin_unlock_irqrestore(&cp->lock, flags);
1227} 1227}
1228 1228
1229#ifdef BROKEN
1230static int cp_change_mtu(struct net_device *dev, int new_mtu) 1229static int cp_change_mtu(struct net_device *dev, int new_mtu)
1231{ 1230{
1232 struct cp_private *cp = netdev_priv(dev); 1231 struct cp_private *cp = netdev_priv(dev);
1233 int rc;
1234 unsigned long flags;
1235 1232
1236 /* check for invalid MTU, according to hardware limits */ 1233 /* check for invalid MTU, according to hardware limits */
1237 if (new_mtu < CP_MIN_MTU || new_mtu > CP_MAX_MTU) 1234 if (new_mtu < CP_MIN_MTU || new_mtu > CP_MAX_MTU)
@@ -1244,22 +1241,12 @@ static int cp_change_mtu(struct net_device *dev, int new_mtu)
1244 return 0; 1241 return 0;
1245 } 1242 }
1246 1243
1247 spin_lock_irqsave(&cp->lock, flags); 1244 /* network IS up, close it, reset MTU, and come up again. */
1248 1245 cp_close(dev);
1249 cp_stop_hw(cp); /* stop h/w and free rings */
1250 cp_clean_rings(cp);
1251
1252 dev->mtu = new_mtu; 1246 dev->mtu = new_mtu;
1253 cp_set_rxbufsize(cp); /* set new rx buf size */ 1247 cp_set_rxbufsize(cp);
1254 1248 return cp_open(dev);
1255 rc = cp_init_rings(cp); /* realloc and restart h/w */
1256 cp_start_hw(cp);
1257
1258 spin_unlock_irqrestore(&cp->lock, flags);
1259
1260 return rc;
1261} 1249}
1262#endif /* BROKEN */
1263 1250
1264static const char mii_2_8139_map[8] = { 1251static const char mii_2_8139_map[8] = {
1265 BasicModeCtrl, 1252 BasicModeCtrl,
@@ -1835,9 +1822,7 @@ static const struct net_device_ops cp_netdev_ops = {
1835 .ndo_start_xmit = cp_start_xmit, 1822 .ndo_start_xmit = cp_start_xmit,
1836 .ndo_tx_timeout = cp_tx_timeout, 1823 .ndo_tx_timeout = cp_tx_timeout,
1837 .ndo_set_features = cp_set_features, 1824 .ndo_set_features = cp_set_features,
1838#ifdef BROKEN
1839 .ndo_change_mtu = cp_change_mtu, 1825 .ndo_change_mtu = cp_change_mtu,
1840#endif
1841 1826
1842#ifdef CONFIG_NET_POLL_CONTROLLER 1827#ifdef CONFIG_NET_POLL_CONTROLLER
1843 .ndo_poll_controller = cp_poll_controller, 1828 .ndo_poll_controller = cp_poll_controller,