Date: Mon, 21 Feb 2011 00:58:51 +0000 (UTC) From: Pyun YongHyeon <yongari@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r218899 - stable/8/sys/dev/re Message-ID: <201102210058.p1L0wphe050476@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: yongari Date: Mon Feb 21 00:58:50 2011 New Revision: 218899 URL: http://svn.freebsd.org/changeset/base/218899 Log: MFC r217247,217381-217382,217384-217385: r217247: When driver is not running, do not send DUMP command to controller and just show old (cached) values. Controller will not respond to the command unless MAC is enabled so DUMP request for down interface caused request timeout. r217381: Allow TX/RX checksum offloading to be configured independently. r217382: re_reset() should be called only after setting device specific features. r217384: Make sure to check validity of dma maps before destroying. r217385: If driver is not able to allocate RX buffer, do not start driver. While I'm here move RX buffer allocation and descriptor initialization up to not touch hardware registers in case of RX buffer allocation failure. Modified: stable/8/sys/dev/re/if_re.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/re/if_re.c ============================================================================== --- stable/8/sys/dev/re/if_re.c Mon Feb 21 00:50:48 2011 (r218898) +++ stable/8/sys/dev/re/if_re.c Mon Feb 21 00:58:50 2011 (r218899) @@ -1258,11 +1258,6 @@ re_attach(device_t dev) CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF); } - /* Reset the adapter. */ - RL_LOCK(sc); - re_reset(sc); - RL_UNLOCK(sc); - hw_rev = re_hwrevs; hwrev = CSR_READ_4(sc, RL_TXCFG); switch (hwrev & 0x70000000) { @@ -1366,6 +1361,11 @@ re_attach(device_t dev) break; } + /* Reset the adapter. */ + RL_LOCK(sc); + re_reset(sc); + RL_UNLOCK(sc); + /* Enable PME. */ CSR_WRITE_1(sc, RL_EECMD, RL_EE_MODE); cfg = CSR_READ_1(sc, RL_CFG1); @@ -1661,15 +1661,19 @@ re_detach(device_t dev) /* Destroy all the RX and TX buffer maps */ if (sc->rl_ldata.rl_tx_mtag) { - for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) - bus_dmamap_destroy(sc->rl_ldata.rl_tx_mtag, - sc->rl_ldata.rl_tx_desc[i].tx_dmamap); + for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) { + if (sc->rl_ldata.rl_tx_desc[i].tx_dmamap) + bus_dmamap_destroy(sc->rl_ldata.rl_tx_mtag, + sc->rl_ldata.rl_tx_desc[i].tx_dmamap); + } bus_dma_tag_destroy(sc->rl_ldata.rl_tx_mtag); } if (sc->rl_ldata.rl_rx_mtag) { - for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) - bus_dmamap_destroy(sc->rl_ldata.rl_rx_mtag, - sc->rl_ldata.rl_rx_desc[i].rx_dmamap); + for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { + if (sc->rl_ldata.rl_rx_desc[i].rx_dmamap) + bus_dmamap_destroy(sc->rl_ldata.rl_rx_mtag, + sc->rl_ldata.rl_rx_desc[i].rx_dmamap); + } if (sc->rl_ldata.rl_rx_sparemap) bus_dmamap_destroy(sc->rl_ldata.rl_rx_mtag, sc->rl_ldata.rl_rx_sparemap); @@ -2616,6 +2620,16 @@ re_init_locked(struct rl_softc *sc) re_reset(sc); /* + * For C+ mode, initialize the RX descriptors and mbufs. + */ + if (re_rx_list_init(sc) != 0) { + device_printf(sc->rl_dev, "no memory for RX buffers\n"); + re_stop(sc); + return; + } + re_tx_list_init(sc); + + /* * Enable C+ RX and TX mode, as well as VLAN stripping and * RX checksum offload. We must configure the C+ register * before all others. @@ -2667,12 +2681,6 @@ re_init_locked(struct rl_softc *sc) CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF); /* - * For C+ mode, initialize the RX descriptors and mbufs. - */ - re_rx_list_init(sc); - re_tx_list_init(sc); - - /* * Load the addresses of the RX and TX lists into the chip. */ @@ -2921,14 +2929,20 @@ re_ioctl(struct ifnet *ifp, u_long comma } } #endif /* DEVICE_POLLING */ - if (mask & IFCAP_HWCSUM) { - ifp->if_capenable ^= IFCAP_HWCSUM; - if (ifp->if_capenable & IFCAP_TXCSUM) + if ((mask & IFCAP_TXCSUM) != 0 && + (ifp->if_capabilities & IFCAP_TXCSUM) != 0) { + ifp->if_capenable ^= IFCAP_TXCSUM; + if ((ifp->if_capenable & IFCAP_TXCSUM) != 0) ifp->if_hwassist |= RE_CSUM_FEATURES; else ifp->if_hwassist &= ~RE_CSUM_FEATURES; reinit = 1; } + if ((mask & IFCAP_RXCSUM) != 0 && + (ifp->if_capabilities & IFCAP_RXCSUM) != 0) { + ifp->if_capenable ^= IFCAP_RXCSUM; + reinit = 1; + } if ((mask & IFCAP_TSO4) != 0 && (ifp->if_capabilities & IFCAP_TSO) != 0) { ifp->if_capenable ^= IFCAP_TSO4; @@ -3281,6 +3295,10 @@ re_sysctl_stats(SYSCTL_HANDLER_ARGS) if (result == 1) { sc = (struct rl_softc *)arg1; RL_LOCK(sc); + if ((sc->rl_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + RL_UNLOCK(sc); + goto done; + } bus_dmamap_sync(sc->rl_ldata.rl_stag, sc->rl_ldata.rl_smap, BUS_DMASYNC_PREREAD); CSR_WRITE_4(sc, RL_DUMPSTATS_HI, @@ -3304,6 +3322,7 @@ re_sysctl_stats(SYSCTL_HANDLER_ARGS) "DUMP statistics request timedout\n"); return (ETIMEDOUT); } +done: stats = sc->rl_ldata.rl_stats; printf("%s statistics:\n", device_get_nameunit(sc->rl_dev)); printf("Tx frames : %ju\n",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102210058.p1L0wphe050476>