From owner-svn-src-projects@FreeBSD.ORG Wed Mar 25 21:53:18 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0B36BF8; Wed, 25 Mar 2015 21:53:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E052D94B; Wed, 25 Mar 2015 21:53:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2PLrH4j025845; Wed, 25 Mar 2015 21:53:17 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2PLrH3S025844; Wed, 25 Mar 2015 21:53:17 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201503252153.t2PLrH3S025844@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 25 Mar 2015 21:53:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r280635 - projects/ifnet/sys/dev/cadence X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2015 21:53:18 -0000 Author: glebius Date: Wed Mar 25 21:53:16 2015 New Revision: 280635 URL: https://svnweb.freebsd.org/changeset/base/280635 Log: Some minor cleanups: - No reason to store cgem_hwassist in softc. We need only generate it in response to SIOCSIFCAP. - Simplify SIOCSIFCAP. - Remove CGEM_DRV_OACTIVE, which is a remembrance about IFF_DRV_OACTIVE, which is descendant of IFF_OACTIVE and was a flag to synchronise the stack and the driver in the era of giant locked kernels. - Do not modify cgem_if_flags in any place except SIOCSIFFLAGS. - Remove unneeded includes. Modified: projects/ifnet/sys/dev/cadence/if_cgem.c Modified: projects/ifnet/sys/dev/cadence/if_cgem.c ============================================================================== --- projects/ifnet/sys/dev/cadence/if_cgem.c Wed Mar 25 21:41:20 2015 (r280634) +++ projects/ifnet/sys/dev/cadence/if_cgem.c Wed Mar 25 21:53:16 2015 (r280635) @@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #ifdef INET #include @@ -64,9 +62,6 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include - #include #include #include @@ -96,7 +91,6 @@ __FBSDID("$FreeBSD$"); CSUM_TCP_IPV6 | CSUM_UDP_IPV6) #define CGEM_DRV_RUNNING 0x0001 -#define CGEM_DRV_OACTIVE 0x0002 struct cgem_softc { if_t ifp; @@ -107,7 +101,6 @@ struct cgem_softc { int cgem_if_flags; int cgem_drv_flags; uint32_t cgem_capenable; - uint64_t cgem_hwassist; struct resource *mem_res; struct resource *irq_res; void *intrhand; @@ -669,8 +662,6 @@ cgem_clean_tx(struct cgem_softc *sc) else sc->txring_tl_ptr++; sc->txring_queued--; - - sc->cgem_drv_flags &= ~CGEM_DRV_OACTIVE; } } @@ -686,9 +677,6 @@ cgem_start_locked(struct cgem_softc *sc) CGEM_ASSERT_LOCKED(sc); - if ((sc->cgem_drv_flags & CGEM_DRV_OACTIVE) != 0) - return; - for (;;) { /* Check that there is room in the descriptor ring. */ if (sc->txring_queued >= @@ -700,7 +688,6 @@ cgem_start_locked(struct cgem_softc *sc) /* Still no room? */ if (sc->txring_queued >= CGEM_NUM_TX_DESCS - TX_MAX_DMA_SEGS * 2) { - sc->cgem_drv_flags |= CGEM_DRV_OACTIVE; sc->txfull++; break; } @@ -1179,24 +1166,17 @@ cgem_ioctl(if_t ifp, u_long cmd, void *d case SIOCSIFCAP: CGEM_LOCK(sc); - mask = sc->cgem_capenable ^ ifr->ifr_reqcap; - + mask = ifr->ifr_reqcap ^ ifr->ifr_curcap; + ifr->ifr_hwassist = 0; if ((mask & IFCAP_TXCSUM) != 0) { if ((ifr->ifr_reqcap & IFCAP_TXCSUM) != 0) { /* Turn on TX checksumming. */ - sc->cgem_capenable |= IFCAP_TXCSUM | - IFCAP_TXCSUM_IPV6; - sc->cgem_hwassist |= CGEM_CKSUM_ASSIST; - + ifr->ifr_hwassist |= CGEM_CKSUM_ASSIST; WR4(sc, CGEM_DMA_CFG, RD4(sc, CGEM_DMA_CFG) | CGEM_DMA_CFG_CHKSUM_GEN_OFFLOAD_EN); } else { /* Turn off TX checksumming. */ - sc->cgem_capenable &= ~(IFCAP_TXCSUM | - IFCAP_TXCSUM_IPV6); - sc->cgem_hwassist &= ~CGEM_CKSUM_ASSIST; - WR4(sc, CGEM_DMA_CFG, RD4(sc, CGEM_DMA_CFG) & ~CGEM_DMA_CFG_CHKSUM_GEN_OFFLOAD_EN); @@ -1205,21 +1185,17 @@ cgem_ioctl(if_t ifp, u_long cmd, void *d if ((mask & IFCAP_RXCSUM) != 0) { if ((ifr->ifr_reqcap & IFCAP_RXCSUM) != 0) { /* Turn on RX checksumming. */ - sc->cgem_capenable |= IFCAP_RXCSUM | - IFCAP_RXCSUM_IPV6; - WR4(sc, CGEM_NET_CFG, RD4(sc, CGEM_NET_CFG) | CGEM_NET_CFG_RX_CHKSUM_OFFLD_EN); } else { /* Turn off RX checksumming. */ - sc->cgem_capenable &= ~(IFCAP_RXCSUM | - IFCAP_RXCSUM_IPV6); WR4(sc, CGEM_NET_CFG, RD4(sc, CGEM_NET_CFG) & ~CGEM_NET_CFG_RX_CHKSUM_OFFLD_EN); } } + sc->cgem_capenable = ifr->ifr_reqcap; CGEM_UNLOCK(sc); break; default: @@ -1673,18 +1649,15 @@ cgem_attach(device_t dev) return (err); } - /* Disable hardware checksumming by default. */ - sc->cgem_hwassist = 0; - sc->cgem_capenable = IFCAP_VLAN_MTU; - sc->rxbufs = DEFAULT_NUM_RX_BUFS; sc->rxhangwar = 1; + /* Disable hardware checksumming by default. */ + ifat.ifat_hwassist = 0; + ifat.ifat_capenable = sc->cgem_capenable = IFCAP_VLAN_MTU; ifat.ifat_softc = sc; ifat.ifat_dunit = device_get_unit(dev); - ifat.ifat_lla =eaddr; - ifat.ifat_hwassist = sc->cgem_hwassist; - ifat.ifat_capenable = sc->cgem_capenable; + ifat.ifat_lla = eaddr; sc->ifp = if_attach(&ifat); /* Set up TX and RX descriptor area. */ @@ -1728,7 +1701,6 @@ cgem_detach(device_t dev) cgem_stop(sc); CGEM_UNLOCK(sc); callout_drain(&sc->tick_ch); - sc->cgem_if_flags &= ~IFF_UP; } if (sc->miibus != NULL) {