svn commit: r213220 - in stable/7/sys/dev: e1000 ixgb ixgbe
Pyun YongHyeon
yongari at FreeBSD.org
Mon Sep 27 18:20:05 UTC 2010
Author: yongari
Date: Mon Sep 27 18:20:04 2010
New Revision: 213220
URL: http://svn.freebsd.org/changeset/base/213220
Log:
MFC r211907:
Do not call voluntary panic(9) in case of if_alloc() failure.
Reviewed by: jfv
Modified:
stable/7/sys/dev/e1000/if_em.c
stable/7/sys/dev/e1000/if_igb.c
stable/7/sys/dev/e1000/if_lem.c
stable/7/sys/dev/ixgb/if_ixgb.c
stable/7/sys/dev/ixgbe/ixgbe.c
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/dev/e1000/if_em.c
==============================================================================
--- stable/7/sys/dev/e1000/if_em.c Mon Sep 27 18:16:28 2010 (r213219)
+++ stable/7/sys/dev/e1000/if_em.c Mon Sep 27 18:20:04 2010 (r213220)
@@ -213,7 +213,7 @@ static int em_setup_msix(struct adapter
static void em_free_pci_resources(struct adapter *);
static void em_local_timer(void *);
static void em_reset(struct adapter *);
-static void em_setup_interface(device_t, struct adapter *);
+static int em_setup_interface(device_t, struct adapter *);
static void em_setup_transmit_structures(struct adapter *);
static void em_initialize_transmit_unit(struct adapter *);
@@ -628,7 +628,8 @@ em_attach(device_t dev)
em_get_wakeup(dev);
/* Setup OS specific network interface */
- em_setup_interface(dev, adapter);
+ if (em_setup_interface(dev, adapter) != 0)
+ goto err_late;
em_reset(adapter);
@@ -669,6 +670,8 @@ err_late:
em_free_transmit_structures(adapter);
em_free_receive_structures(adapter);
em_release_hw_control(adapter);
+ if (adapter->ifp != NULL)
+ if_free(adapter->ifp);
err_pci:
em_free_pci_resources(adapter);
EM_CORE_LOCK_DESTROY(adapter);
@@ -2644,7 +2647,7 @@ em_reset(struct adapter *adapter)
* Setup networking device structure and register an interface.
*
**********************************************************************/
-static void
+static int
em_setup_interface(device_t dev, struct adapter *adapter)
{
struct ifnet *ifp;
@@ -2652,8 +2655,10 @@ em_setup_interface(device_t dev, struct
INIT_DEBUGOUT("em_setup_interface: begin");
ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL)
- panic("%s: can not if_alloc()", device_get_nameunit(dev));
+ if (ifp == NULL) {
+ device_printf(dev, "can not allocate ifnet structure\n");
+ return (-1);
+ }
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_init = em_init;
@@ -2740,6 +2745,7 @@ em_setup_interface(device_t dev, struct
}
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
+ return (0);
}
Modified: stable/7/sys/dev/e1000/if_igb.c
==============================================================================
--- stable/7/sys/dev/e1000/if_igb.c Mon Sep 27 18:16:28 2010 (r213219)
+++ stable/7/sys/dev/e1000/if_igb.c Mon Sep 27 18:20:04 2010 (r213220)
@@ -177,7 +177,7 @@ static int igb_setup_msix(struct adapter
static void igb_free_pci_resources(struct adapter *);
static void igb_local_timer(void *);
static void igb_reset(struct adapter *);
-static void igb_setup_interface(device_t, struct adapter *);
+static int igb_setup_interface(device_t, struct adapter *);
static int igb_allocate_queues(struct adapter *);
static void igb_configure_queues(struct adapter *);
@@ -543,7 +543,8 @@ igb_attach(device_t dev)
goto err_late;
/* Setup OS specific network interface */
- igb_setup_interface(dev, adapter);
+ if (igb_setup_interface(dev, adapter) != 0)
+ goto err_late;
/* Now get a good starting state */
igb_reset(adapter);
@@ -592,6 +593,8 @@ err_late:
igb_free_transmit_structures(adapter);
igb_free_receive_structures(adapter);
igb_release_hw_control(adapter);
+ if (adapter->ifp != NULL)
+ if_free(adapter->ifp);
err_pci:
igb_free_pci_resources(adapter);
IGB_CORE_LOCK_DESTROY(adapter);
@@ -2615,7 +2618,7 @@ igb_reset(struct adapter *adapter)
* Setup networking device structure and register an interface.
*
**********************************************************************/
-static void
+static int
igb_setup_interface(device_t dev, struct adapter *adapter)
{
struct ifnet *ifp;
@@ -2623,8 +2626,10 @@ igb_setup_interface(device_t dev, struct
INIT_DEBUGOUT("igb_setup_interface: begin");
ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL)
- panic("%s: can not if_alloc()", device_get_nameunit(dev));
+ if (ifp == NULL) {
+ device_printf(dev, "can not allocate ifnet structure\n");
+ return (-1);
+ }
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_init = igb_init;
@@ -2701,6 +2706,7 @@ igb_setup_interface(device_t dev, struct
}
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
+ return (0);
}
Modified: stable/7/sys/dev/e1000/if_lem.c
==============================================================================
--- stable/7/sys/dev/e1000/if_lem.c Mon Sep 27 18:16:28 2010 (r213219)
+++ stable/7/sys/dev/e1000/if_lem.c Mon Sep 27 18:20:04 2010 (r213220)
@@ -181,7 +181,7 @@ static int lem_allocate_irq(struct adapt
static void lem_free_pci_resources(struct adapter *);
static void lem_local_timer(void *);
static int lem_hardware_init(struct adapter *);
-static void lem_setup_interface(device_t, struct adapter *);
+static int lem_setup_interface(device_t, struct adapter *);
static void lem_setup_transmit_structures(struct adapter *);
static void lem_initialize_transmit_unit(struct adapter *);
static int lem_setup_receive_structures(struct adapter *);
@@ -608,7 +608,8 @@ lem_attach(device_t dev)
lem_get_wakeup(dev);
/* Setup OS specific network interface */
- lem_setup_interface(dev, adapter);
+ if (lem_setup_interface(dev, adapter) != 0)
+ goto err_rx_struct;
/* Initialize statistics */
lem_update_stats_counters(adapter);
@@ -662,6 +663,8 @@ err_rx_desc:
lem_dma_free(adapter, &adapter->txdma);
err_tx_desc:
err_pci:
+ if (adapter->ifp != NULL)
+ if_free(adapter->ifp);
lem_free_pci_resources(adapter);
EM_TX_LOCK_DESTROY(adapter);
EM_RX_LOCK_DESTROY(adapter);
@@ -2373,7 +2376,7 @@ lem_hardware_init(struct adapter *adapte
* Setup networking device structure and register an interface.
*
**********************************************************************/
-static void
+static int
lem_setup_interface(device_t dev, struct adapter *adapter)
{
struct ifnet *ifp;
@@ -2381,8 +2384,10 @@ lem_setup_interface(device_t dev, struct
INIT_DEBUGOUT("lem_setup_interface: begin");
ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL)
- panic("%s: can not if_alloc()", device_get_nameunit(dev));
+ if (ifp == NULL) {
+ device_printf(dev, "can not allocate ifnet structure\n");
+ return (-1);
+ }
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_init = lem_init;
@@ -2458,6 +2463,7 @@ lem_setup_interface(device_t dev, struct
}
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
+ return (0);
}
Modified: stable/7/sys/dev/ixgb/if_ixgb.c
==============================================================================
--- stable/7/sys/dev/ixgb/if_ixgb.c Mon Sep 27 18:16:28 2010 (r213219)
+++ stable/7/sys/dev/ixgb/if_ixgb.c Mon Sep 27 18:20:04 2010 (r213220)
@@ -108,7 +108,7 @@ static int ixgb_allocate_pci_resour
static void ixgb_free_pci_resources(struct adapter *);
static void ixgb_local_timer(void *);
static int ixgb_hardware_init(struct adapter *);
-static void ixgb_setup_interface(device_t, struct adapter *);
+static int ixgb_setup_interface(device_t, struct adapter *);
static int ixgb_setup_transmit_structures(struct adapter *);
static void ixgb_initialize_transmit_unit(struct adapter *);
static int ixgb_setup_receive_structures(struct adapter *);
@@ -336,7 +336,8 @@ ixgb_attach(device_t dev)
goto err_hw_init;
}
/* Setup OS specific network interface */
- ixgb_setup_interface(dev, adapter);
+ if (ixgb_setup_interface(dev, adapter) != 0)
+ goto err_hw_init;
/* Initialize statistics */
ixgb_clear_hw_cntrs(&adapter->hw);
@@ -351,6 +352,8 @@ err_rx_desc:
ixgb_dma_free(adapter, &adapter->txdma);
err_tx_desc:
err_pci:
+ if (adapter->ifp != NULL)
+ if_free(adapter->ifp);
ixgb_free_pci_resources(adapter);
sysctl_ctx_free(&adapter->sysctl_ctx);
return (error);
@@ -1336,15 +1339,17 @@ ixgb_hardware_init(struct adapter * adap
* Setup networking device structure and register an interface.
*
**********************************************************************/
-static void
+static int
ixgb_setup_interface(device_t dev, struct adapter * adapter)
{
struct ifnet *ifp;
INIT_DEBUGOUT("ixgb_setup_interface: begin");
ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL)
- panic("%s: can not if_alloc()\n", device_get_nameunit(dev));
+ if (ifp == NULL) {
+ device_printf(dev, "can not allocate ifnet structure\n");
+ return (-1);
+ }
#if __FreeBSD_version >= 502000
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
#else
@@ -1397,7 +1402,7 @@ ixgb_setup_interface(device_t dev, struc
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
- return;
+ return (0);
}
/********************************************************************
Modified: stable/7/sys/dev/ixgbe/ixgbe.c
==============================================================================
--- stable/7/sys/dev/ixgbe/ixgbe.c Mon Sep 27 18:16:28 2010 (r213219)
+++ stable/7/sys/dev/ixgbe/ixgbe.c Mon Sep 27 18:20:04 2010 (r213220)
@@ -112,7 +112,7 @@ static int ixgbe_setup_msix(struct adapt
static void ixgbe_free_pci_resources(struct adapter *);
static void ixgbe_local_timer(void *);
static int ixgbe_hardware_init(struct adapter *);
-static void ixgbe_setup_interface(device_t, struct adapter *);
+static int ixgbe_setup_interface(device_t, struct adapter *);
static int ixgbe_allocate_transmit_buffers(struct tx_ring *);
static int ixgbe_setup_transmit_structures(struct adapter *);
@@ -535,7 +535,8 @@ ixgbe_attach(device_t dev)
goto err_late;
/* Setup OS specific network interface */
- ixgbe_setup_interface(dev, adapter);
+ if (ixgbe_setup_interface(dev, adapter) != 0)
+ goto err_late;
/* Sysctl for limiting the amount of work done in the taskqueue */
ixgbe_add_rx_process_limit(adapter, "rx_processing_limit",
@@ -564,6 +565,8 @@ err_late:
ixgbe_free_transmit_structures(adapter);
ixgbe_free_receive_structures(adapter);
err_out:
+ if (adapter->ifp != NULL)
+ if_free(adapter->ifp);
ixgbe_free_pci_resources(adapter);
return (error);
@@ -2375,7 +2378,7 @@ ixgbe_hardware_init(struct adapter *adap
* Setup networking device structure and register an interface.
*
**********************************************************************/
-static void
+static int
ixgbe_setup_interface(device_t dev, struct adapter *adapter)
{
struct ifnet *ifp;
@@ -2383,8 +2386,10 @@ ixgbe_setup_interface(device_t dev, stru
INIT_DEBUGOUT("ixgbe_setup_interface: begin");
ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL)
- panic("%s: can not if_alloc()\n", device_get_nameunit(dev));
+ if (ifp == NULL) {
+ device_printf(dev, "can not allocate ifnet structure\n");
+ return (-1);
+ }
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_baudrate = 1000000000;
@@ -2437,7 +2442,7 @@ ixgbe_setup_interface(device_t dev, stru
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
- return;
+ return (0);
}
/********************************************************************
More information about the svn-src-all
mailing list