From owner-svn-src-all@FreeBSD.ORG Sat Aug 28 00:09:19 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C04410656C3; Sat, 28 Aug 2010 00:09:19 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A5D58FC16; Sat, 28 Aug 2010 00:09:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7S09Jjx011926; Sat, 28 Aug 2010 00:09:19 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7S09Jt9011920; Sat, 28 Aug 2010 00:09:19 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201008280009.o7S09Jt9011920@svn.freebsd.org> From: Pyun YongHyeon Date: Sat, 28 Aug 2010 00:09:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211907 - in head/sys/dev: e1000 ixgb ixgbe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2010 00:09:19 -0000 Author: yongari Date: Sat Aug 28 00:09:19 2010 New Revision: 211907 URL: http://svn.freebsd.org/changeset/base/211907 Log: Do not call voluntary panic(9) in case of if_alloc() failure. Reviewed by: jfv Modified: head/sys/dev/e1000/if_em.c head/sys/dev/e1000/if_igb.c head/sys/dev/e1000/if_lem.c head/sys/dev/ixgb/if_ixgb.c head/sys/dev/ixgbe/ixgbe.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Fri Aug 27 23:50:13 2010 (r211906) +++ head/sys/dev/e1000/if_em.c Sat Aug 28 00:09:19 2010 (r211907) @@ -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); @@ -2646,7 +2649,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; @@ -2654,8 +2657,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; @@ -2742,6 +2747,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: head/sys/dev/e1000/if_igb.c ============================================================================== --- head/sys/dev/e1000/if_igb.c Fri Aug 27 23:50:13 2010 (r211906) +++ head/sys/dev/e1000/if_igb.c Sat Aug 28 00:09:19 2010 (r211907) @@ -178,7 +178,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 *); @@ -564,7 +564,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); @@ -613,6 +614,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); @@ -2658,7 +2661,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; @@ -2666,8 +2669,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; @@ -2744,6 +2749,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: head/sys/dev/e1000/if_lem.c ============================================================================== --- head/sys/dev/e1000/if_lem.c Fri Aug 27 23:50:13 2010 (r211906) +++ head/sys/dev/e1000/if_lem.c Sat Aug 28 00:09:19 2010 (r211907) @@ -186,7 +186,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 *); @@ -620,7 +620,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); @@ -672,6 +673,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); @@ -2388,7 +2391,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; @@ -2396,8 +2399,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; @@ -2473,6 +2478,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: head/sys/dev/ixgb/if_ixgb.c ============================================================================== --- head/sys/dev/ixgb/if_ixgb.c Fri Aug 27 23:50:13 2010 (r211906) +++ head/sys/dev/ixgb/if_ixgb.c Sat Aug 28 00:09:19 2010 (r211907) @@ -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 *); @@ -331,7 +331,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); @@ -346,6 +347,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); @@ -1319,15 +1322,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 @@ -1379,7 +1384,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: head/sys/dev/ixgbe/ixgbe.c ============================================================================== --- head/sys/dev/ixgbe/ixgbe.c Fri Aug 27 23:50:13 2010 (r211906) +++ head/sys/dev/ixgbe/ixgbe.c Sat Aug 28 00:09:19 2010 (r211907) @@ -119,7 +119,7 @@ static int ixgbe_allocate_queues(struct static int ixgbe_setup_msix(struct adapter *); static void ixgbe_free_pci_resources(struct adapter *); static void ixgbe_local_timer(void *); -static void ixgbe_setup_interface(device_t, struct adapter *); +static int ixgbe_setup_interface(device_t, struct adapter *); static void ixgbe_config_link(struct adapter *); static int ixgbe_allocate_transmit_buffers(struct tx_ring *); @@ -586,7 +586,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", @@ -632,6 +633,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); @@ -2357,7 +2360,7 @@ mem: * Setup networking device structure and register an interface. * **********************************************************************/ -static void +static int ixgbe_setup_interface(device_t dev, struct adapter *adapter) { struct ixgbe_hw *hw = &adapter->hw; @@ -2366,8 +2369,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; @@ -2415,7 +2420,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); } static void