From owner-svn-src-all@freebsd.org Mon Oct 3 19:48:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C68EAAF45F3; Mon, 3 Oct 2016 19:48:57 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 9F72D7CE; Mon, 3 Oct 2016 19:48:57 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u93JmuS6077674; Mon, 3 Oct 2016 19:48:56 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u93Jmuoa077673; Mon, 3 Oct 2016 19:48:56 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201610031948.u93Jmuoa077673@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Mon, 3 Oct 2016 19:48:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306654 - head/sys/arm/ti/cpsw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 03 Oct 2016 19:48:57 -0000 Author: loos Date: Mon Oct 3 19:48:56 2016 New Revision: 306654 URL: https://svnweb.freebsd.org/changeset/base/306654 Log: Enable the TX completion interrupt for the cpsw NIC to assure the free tx descriptors are reclaimed as soon as possible. Without this the free buffers are reclaimed only on watchdog runs or after trying to enqueue more packets. Sponsored by: Rubicon Communications, LLC (Netgte) Modified: head/sys/arm/ti/cpsw/if_cpsw.c Modified: head/sys/arm/ti/cpsw/if_cpsw.c ============================================================================== --- head/sys/arm/ti/cpsw/if_cpsw.c Mon Oct 3 19:34:32 2016 (r306653) +++ head/sys/arm/ti/cpsw/if_cpsw.c Mon Oct 3 19:48:56 2016 (r306654) @@ -117,6 +117,7 @@ static void cpsw_intr_rx(void *arg); static struct mbuf *cpsw_rx_dequeue(struct cpsw_softc *); static void cpsw_rx_enqueue(struct cpsw_softc *); static void cpswp_start(struct ifnet *); +static void cpsw_intr_tx(void *); static void cpswp_tx_enqueue(struct cpswp_softc *); static int cpsw_tx_dequeue(struct cpsw_softc *); @@ -209,6 +210,15 @@ static struct resource_spec irq_res_spec { -1, 0 } }; +static struct { + void (*cb)(void *); +} cpsw_intr_cb[] = { + { cpsw_intr_rx_thresh }, + { cpsw_intr_rx }, + { cpsw_intr_tx }, + { cpsw_intr_misc }, +}; + /* Number of entries here must match size of stats * array in struct cpswp_softc. */ static struct cpsw_stat { @@ -590,13 +600,15 @@ cpsw_init(struct cpsw_softc *sc) /* Enable Interrupts for core 0 */ cpsw_write_4(sc, CPSW_WR_C_RX_THRESH_EN(0), 0xFF); cpsw_write_4(sc, CPSW_WR_C_RX_EN(0), 0xFF); + cpsw_write_4(sc, CPSW_WR_C_TX_EN(0), 0xFF); cpsw_write_4(sc, CPSW_WR_C_MISC_EN(0), 0x1F); /* Enable host Error Interrupt */ cpsw_write_4(sc, CPSW_CPDMA_DMA_INTMASK_SET, 3); - /* Enable interrupts for RX Channel 0 */ + /* Enable interrupts for RX and TX on Channel 0 */ cpsw_write_4(sc, CPSW_CPDMA_RX_INTMASK_SET, 1); + cpsw_write_4(sc, CPSW_CPDMA_TX_INTMASK_SET, 1); /* Initialze MDIO - ENABLE, PREAMBLE=0, FAULTENB, CLKDIV=0xFF */ /* TODO Calculate MDCLK=CLK/(CLKDIV+1) */ @@ -645,22 +657,14 @@ cpsw_probe(device_t dev) static int cpsw_intr_attach(struct cpsw_softc *sc) { + int i; - /* Note: We don't use sc->irq_res[2] (TX interrupt) */ - if (bus_setup_intr(sc->dev, sc->irq_res[0], - INTR_TYPE_NET | INTR_MPSAFE, NULL, cpsw_intr_rx_thresh, - sc, &sc->ih_cookie[0]) != 0) { - return (-1); - } - if (bus_setup_intr(sc->dev, sc->irq_res[1], - INTR_TYPE_NET | INTR_MPSAFE, NULL, cpsw_intr_rx, - sc, &sc->ih_cookie[1]) != 0) { - return (-1); - } - if (bus_setup_intr(sc->dev, sc->irq_res[3], - INTR_TYPE_NET | INTR_MPSAFE, NULL, cpsw_intr_misc, - sc, &sc->ih_cookie[3]) != 0) { - return (-1); + for (i = 0; i < CPSW_INTR_COUNT; i++) { + if (bus_setup_intr(sc->dev, sc->irq_res[i], + INTR_TYPE_NET | INTR_MPSAFE, NULL, + cpsw_intr_cb[i].cb, sc, &sc->ih_cookie[i]) != 0) { + return (-1); + } } return (0); @@ -1696,6 +1700,18 @@ cpswp_start(struct ifnet *ifp) } static void +cpsw_intr_tx(void *arg) +{ + struct cpsw_softc *sc; + + sc = (struct cpsw_softc *)arg; + CPSW_TX_LOCK(sc); + cpsw_tx_dequeue(sc); + cpsw_write_4(sc, CPSW_CPDMA_CPDMA_EOI_VECTOR, 2); + CPSW_TX_UNLOCK(sc); +} + +static void cpswp_tx_enqueue(struct cpswp_softc *sc) { bus_dma_segment_t segs[CPSW_TXFRAGS];