From owner-svn-src-stable-7@FreeBSD.ORG Mon Feb 21 01:01:26 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 805691065672; Mon, 21 Feb 2011 01:01:26 +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 6D5FD8FC0A; Mon, 21 Feb 2011 01:01:26 +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 p1L11QbM050655; Mon, 21 Feb 2011 01:01:26 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1L11Qj7050653; Mon, 21 Feb 2011 01:01:26 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201102210101.p1L11Qj7050653@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 21 Feb 2011 01:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218900 - stable/7/sys/dev/re X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Feb 2011 01:01:26 -0000 Author: yongari Date: Mon Feb 21 01:01:26 2011 New Revision: 218900 URL: http://svn.freebsd.org/changeset/base/218900 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/7/sys/dev/re/if_re.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/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Mon Feb 21 00:58:50 2011 (r218899) +++ stable/7/sys/dev/re/if_re.c Mon Feb 21 01:01:26 2011 (r218900) @@ -1259,11 +1259,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) { @@ -1367,6 +1362,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); @@ -1662,15 +1662,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); @@ -2610,6 +2614,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. @@ -2661,12 +2675,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. */ @@ -2915,14 +2923,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; @@ -3275,6 +3289,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, @@ -3298,6 +3316,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",