Date: Tue, 10 Aug 2010 14:37:54 -0700 From: Pyun YongHyeon <pyunyh@gmail.com> To: Victor Ophof <mr4hughz@hotmail.com> Cc: Jack F Vogel <jfv@freebsd.org>, freebsd-net@freebsd.org Subject: Re: "RX ring hdr initialization error" Message-ID: <20100810213754.GH6960@michelle.cdnetworks.com> In-Reply-To: <SNT142-w4884CF1F51C4F993E7D6C8C950@phx.gbl> References: <SNT142-w4884CF1F51C4F993E7D6C8C950@phx.gbl>
next in thread | previous in thread | raw e-mail | index | archive | help
--mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 10, 2010 at 12:52:56PM +0200, Victor Ophof wrote: > > > > > Hi > > I've bought a asus M4a78-EM Motherboard. to build a NAS on, > thinking the onboard Realtek would be sufficant speed > unfortunatly the onboard fives 16/31 mbs at best > > ps later It improved with enabeling "polling" in the kernel (duh) > > so I had a PCI intel GT nic around, what gave intermittent tcp/ip connections in a other machine (ESXi) > unfortunatly this was the same with Freebsd (card issue?) The card is still in the machine > even with the Intel supplied BSD driver > > now I bought a PCIe intel CT nic, put it in and the kernel panic with > "RX ring hdr initialization error" > so replaced the intel with the freebsd one by doing > intel overwrites the freebsd one /boot/kernel/if_em.ko > # cd /usr/src/sys/modules/em/ && make obj depend all install > (was already in the kernel) > > > still panic > anybody got some idea's howto fix ? > I have been using the attached patch for em(4)/igb(4) controllers. These drivers explicitly calls panic(9) when memory allocation failure happens. I don't think it's good idea to panic the box under resource shortage condition as it's common to see this situation on heavily loaded servers. The patch does not solve the one issue yet. The panic caused by RX buffer allocation failure condition which in turn means you're allocating a lot of buffers. Reduce number of descriptors if you increased that too high and see whether the issue could be gone. --mYCpIKhGyMATD0i+ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="em.igb.ix.patch" Index: sys/dev/e1000/if_igb.c =================================================================== --- sys/dev/e1000/if_igb.c (revision 211102) +++ sys/dev/e1000/if_igb.c (working copy) @@ -178,7 +178,7 @@ 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 *); @@ -559,7 +559,8 @@ 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); @@ -608,6 +609,8 @@ 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); @@ -2653,7 +2656,7 @@ * Setup networking device structure and register an interface. * **********************************************************************/ -static void +static int igb_setup_interface(device_t dev, struct adapter *adapter) { struct ifnet *ifp; @@ -2661,8 +2664,10 @@ 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; @@ -2739,6 +2744,7 @@ } ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + return (0); } Index: sys/dev/e1000/if_lem.c =================================================================== --- sys/dev/e1000/if_lem.c (revision 211102) +++ sys/dev/e1000/if_lem.c (working copy) @@ -186,7 +186,7 @@ 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_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 @@ 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); @@ -1939,6 +1942,19 @@ IOCTL_DEBUGOUT("lem_set_multi: begin"); + /* + * Allocate temporary memory to setup array. If there is not + * enough resource, give up setting multicast filter. + */ + mta = malloc(sizeof(u8) * + (ETH_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES), + M_DEVBUF, M_NOWAIT | M_ZERO); + if (mta == NULL) { + device_printf(adapter->dev, + "can not allocate multicast setup array\n"); + return; + } + if (adapter->hw.mac.type == e1000_82542 && adapter->hw.revision_id == E1000_REVISION_2) { reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); @@ -1949,13 +1965,6 @@ msec_delay(5); } - /* Allocate temporary memory to setup array */ - mta = malloc(sizeof(u8) * - (ETH_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (mta == NULL) - panic("lem_set_multi memory failure\n"); - #if __FreeBSD_version < 800000 IF_ADDR_LOCK(ifp); #else @@ -2388,7 +2397,7 @@ * 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 +2405,10 @@ 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 +2484,7 @@ } ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + return (0); } Index: sys/dev/e1000/if_em.c =================================================================== --- sys/dev/e1000/if_em.c (revision 211102) +++ sys/dev/e1000/if_em.c (working copy) @@ -213,7 +213,7 @@ 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_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 @@ 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); @@ -1995,6 +1998,19 @@ IOCTL_DEBUGOUT("em_set_multi: begin"); + /* + * Allocate temporary memory to setup array. If there is not + * enough resource, give up setting multicast filter. + */ + mta = malloc(sizeof(u8) * + (ETH_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES), + M_DEVBUF, M_NOWAIT | M_ZERO); + if (mta == NULL) { + device_printf(adapter->dev, + "can not allocate multicast setup array\n"); + return; + } + if (adapter->hw.mac.type == e1000_82542 && adapter->hw.revision_id == E1000_REVISION_2) { reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL); @@ -2005,13 +2021,6 @@ msec_delay(5); } - /* Allocate temporary memory to setup array */ - mta = malloc(sizeof(u8) * - (ETH_ADDR_LEN * MAX_NUM_MULTICAST_ADDRESSES), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (mta == NULL) - panic("em_set_multi memory failure\n"); - #if __FreeBSD_version < 800000 IF_ADDR_LOCK(ifp); #else @@ -2646,7 +2655,7 @@ * 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 +2663,10 @@ 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 +2753,7 @@ } ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + return (0); } @@ -3837,7 +3849,7 @@ rxbuf = &rxr->rx_buffers[j]; rxbuf->m_head = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); if (rxbuf->m_head == NULL) - panic("RX ring hdr initialization failed!\n"); + return (ENOBUFS); rxbuf->m_head->m_len = MCLBYTES; rxbuf->m_head->m_flags &= ~M_HASFCS; /* we strip it */ rxbuf->m_head->m_pkthdr.len = MCLBYTES; @@ -3846,8 +3858,11 @@ error = bus_dmamap_load_mbuf_sg(rxr->rxtag, rxbuf->map, rxbuf->m_head, seg, &nsegs, BUS_DMA_NOWAIT); - if (error != 0) - panic("RX ring dma initialization failed!\n"); + if (error != 0) { + m_freem(rxbuf->m_head); + rxbuf->m_head = NULL; + return (error); + } bus_dmamap_sync(rxr->rxtag, rxbuf->map, BUS_DMASYNC_PREREAD); Index: sys/dev/ixgb/if_ixgb.c =================================================================== --- sys/dev/ixgb/if_ixgb.c (revision 211102) +++ sys/dev/ixgb/if_ixgb.c (working copy) @@ -108,7 +108,7 @@ 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 @@ 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 @@ 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 @@ * 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 @@ ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); - return; + return (0); } /******************************************************************** Index: sys/dev/ixgbe/ixgbe.c =================================================================== --- sys/dev/ixgbe/ixgbe.c (revision 211102) +++ sys/dev/ixgbe/ixgbe.c (working copy) @@ -119,7 +119,7 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); - return; + return (0); } static void --mYCpIKhGyMATD0i+--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100810213754.GH6960>