aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/skge.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2005-12-14 18:47:46 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-12-24 09:36:05 -0500
commit7731a4ea1bbb7c9336bcdec8ef4050cf08a35268 (patch)
tree2aa5dbad868dbaa1bd60972abcd9dcb9ac66fdba /drivers/net/skge.c
parente8df8554605f014765732605667145c0824a12b7 (diff)
[PATCH] skge: handle out of memory on MTU size changes
Changing the MTU size causes the receiver to have to reallocate buffers. If this allocation fails, then we need to return an error, and take the device offline. It can then be brought back up or reconfigured for a smaller MTU. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/skge.c')
-rw-r--r--drivers/net/skge.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 14bf4cc5b07b..96b661b1f6c0 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2192,6 +2192,7 @@ static int skge_up(struct net_device *dev)
2192 kfree(skge->rx_ring.start); 2192 kfree(skge->rx_ring.start);
2193 free_pci_mem: 2193 free_pci_mem:
2194 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma); 2194 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
2195 skge->mem = NULL;
2195 2196
2196 return err; 2197 return err;
2197} 2198}
@@ -2202,6 +2203,9 @@ static int skge_down(struct net_device *dev)
2202 struct skge_hw *hw = skge->hw; 2203 struct skge_hw *hw = skge->hw;
2203 int port = skge->port; 2204 int port = skge->port;
2204 2205
2206 if (skge->mem == NULL)
2207 return 0;
2208
2205 if (netif_msg_ifdown(skge)) 2209 if (netif_msg_ifdown(skge))
2206 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 2210 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
2207 2211
@@ -2258,6 +2262,7 @@ static int skge_down(struct net_device *dev)
2258 kfree(skge->rx_ring.start); 2262 kfree(skge->rx_ring.start);
2259 kfree(skge->tx_ring.start); 2263 kfree(skge->tx_ring.start);
2260 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma); 2264 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
2265 skge->mem = NULL;
2261 return 0; 2266 return 0;
2262} 2267}
2263 2268
@@ -2418,18 +2423,23 @@ static void skge_tx_timeout(struct net_device *dev)
2418 2423
2419static int skge_change_mtu(struct net_device *dev, int new_mtu) 2424static int skge_change_mtu(struct net_device *dev, int new_mtu)
2420{ 2425{
2421 int err = 0; 2426 int err;
2422 int running = netif_running(dev);
2423 2427
2424 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) 2428 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
2425 return -EINVAL; 2429 return -EINVAL;
2426 2430
2431 if (!netif_running(dev)) {
2432 dev->mtu = new_mtu;
2433 return 0;
2434 }
2435
2436 skge_down(dev);
2427 2437
2428 if (running)
2429 skge_down(dev);
2430 dev->mtu = new_mtu; 2438 dev->mtu = new_mtu;
2431 if (running) 2439
2432 skge_up(dev); 2440 err = skge_up(dev);
2441 if (err)
2442 dev_close(dev);
2433 2443
2434 return err; 2444 return err;
2435} 2445}