From owner-svn-src-user@FreeBSD.ORG Sun Jun 7 00:02:53 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D9611065670; Sun, 7 Jun 2009 00:02:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BB498FC19; Sun, 7 Jun 2009 00:02:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5702qqX075270; Sun, 7 Jun 2009 00:02:52 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5702qP7075266; Sun, 7 Jun 2009 00:02:52 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200906070002.n5702qP7075266@svn.freebsd.org> From: Kip Macy Date: Sun, 7 Jun 2009 00:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193598 - in user/kmacy/releng_7_2_fcs/sys/dev/cxgb: . sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2009 00:02:53 -0000 Author: kmacy Date: Sun Jun 7 00:02:52 2009 New Revision: 193598 URL: http://svn.freebsd.org/changeset/base/193598 Log: - minimize the number of descriptors that are used by a delayed transmit / watchdog - add once per second watchdog Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_adapter.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_main.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_adapter.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_adapter.h Sat Jun 6 22:20:41 2009 (r193597) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_adapter.h Sun Jun 7 00:02:52 2009 (r193598) @@ -243,6 +243,7 @@ struct sge_txq { struct buf_ring *txq_mr; struct ifaltq *txq_ifq; struct callout txq_timer; + struct callout txq_watchdog; uint32_t txq_drops; uint32_t txq_skipped; uint32_t txq_coalesced; @@ -267,6 +268,7 @@ enum { #define QS_EXITING 0x1 #define QS_RUNNING 0x2 #define QS_BOUND 0x4 +#define QS_FLUSHING 0x8 struct sge_qset { struct sge_rspq rspq; @@ -562,9 +564,8 @@ static inline int offload_running(adapte return isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); } +void cxgb_tx_watchdog(void *arg); int cxgb_transmit(struct ifnet *ifp, struct mbuf *m); void cxgb_qflush(struct ifnet *ifp); -int process_responses(adapter_t *adap, struct sge_qset *qs, int budget); void cxgb_start(struct ifnet *ifp); -void refill_fl_service(adapter_t *adap, struct sge_fl *fl); #endif Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_main.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_main.c Sat Jun 6 22:20:41 2009 (r193597) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_main.c Sun Jun 7 00:02:52 2009 (r193598) @@ -1936,7 +1936,7 @@ cxgb_init_locked(struct port_info *p) { struct ifnet *ifp; adapter_t *sc = p->adapter; - int err; + int i, err; PORT_LOCK_ASSERT_OWNED(p); ifp = p->ifp; @@ -1972,11 +1972,18 @@ cxgb_init_locked(struct port_info *p) device_printf(sc->dev, "enabling interrupts on port=%d\n", p->port_id); t3_port_intr_enable(sc, p->port_id); - callout_reset(&sc->cxgb_tick_ch, CXGB_TICKS(sc), cxgb_tick, sc); t3_sge_reset_adapter(sc); ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + callout_reset(&sc->cxgb_tick_ch, CXGB_TICKS(sc), cxgb_tick, sc); + for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) { + struct sge_qset *qs = &sc->sge.qs[i]; + struct sge_txq *txq = &qs->txq[TXQ_ETH]; + + callout_reset_on(&txq->txq_watchdog, hz, cxgb_tx_watchdog, + qs, txq->txq_watchdog.c_cpu); + } } static void Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c Sat Jun 6 22:20:41 2009 (r193597) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c Sun Jun 7 00:02:52 2009 (r193598) @@ -704,12 +704,6 @@ __refill_fl_lt(adapter_t *adap, struct s refill_fl(adap, fl, min(max, fl->size - fl->credits)); } -void -refill_fl_service(adapter_t *adap, struct sge_fl *fl) -{ - __refill_fl_lt(adap, fl, 512); -} - /** * recycle_rx_buf - recycle a receive buffer * @adapter: the adapter @@ -1327,7 +1321,7 @@ t3_encap(struct sge_qset *qs, struct mbu return (err); } KASSERT(m0->m_pkthdr.len, ("empty packet nsegs=%d", nsegs)); - txsd->m = m0; + txsd->m = m0; if (m0->m_nextpkt != NULL) { struct cpl_tx_pkt_batch *cpl_batch = (struct cpl_tx_pkt_batch *)txd; @@ -1491,13 +1485,33 @@ t3_encap(struct sge_qset *qs, struct mbu return (0); } +void +cxgb_tx_watchdog(void *arg) +{ + struct sge_qset *qs = arg; + struct sge_txq *txq = &qs->txq[TXQ_ETH]; + + if (TXQ_TRYLOCK(qs)) { + qs->qs_flags |= QS_FLUSHING; + cxgb_start_locked(qs); + qs->qs_flags &= ~QS_FLUSHING; + TXQ_UNLOCK(qs); + } + if (qs->port->ifp->if_drv_flags & IFF_DRV_RUNNING) + callout_reset_on(&txq->txq_watchdog, hz, cxgb_tx_watchdog, + qs, txq->txq_watchdog.c_cpu); +} + + static void cxgb_tx_timeout(void *arg) { struct sge_qset *qs = arg; if (TXQ_TRYLOCK(qs)) { + qs->qs_flags |= QS_FLUSHING; cxgb_start_locked(qs); + qs->qs_flags &= ~QS_FLUSHING; TXQ_UNLOCK(qs); } } @@ -1564,6 +1578,10 @@ cxgb_start_locked(struct sge_qset *qs) avail = txq->size - txq->in_use - 4; txmax = min(TX_START_MAX_DESC, avail); + /* in case all packets use more than one mbuf */ + if (qs->qs_flags & QS_FLUSHING) + txmax = min(txmax, 7); + TXQ_LOCK_ASSERT(qs); while ((txq->in_use - in_use_init < txmax) && (!TXQ_RING_EMPTY(qs)) && @@ -1620,7 +1638,8 @@ cxgb_transmit_locked(struct ifnet *ifp, * - there are no packets enqueued already * - there is space in hardware transmit queue */ - if (sc->tunq_coalesce == 0 && pi->link_config.link_ok && + if (sc->tunq_coalesce == 0 && + pi->link_config.link_ok && TXQ_RING_EMPTY(qs) && avail > 4) { if (t3_encap(qs, &m)) { if (m != NULL && @@ -2501,7 +2520,9 @@ t3_sge_alloc_qset(adapter_t *sc, u_int i } ifq_attach(q->txq[i].txq_ifq, pi->ifp); callout_init(&q->txq[i].txq_timer, 1); + callout_init(&q->txq[i].txq_watchdog, 1); q->txq[i].txq_timer.c_cpu = id % mp_ncpus; + q->txq[i].txq_watchdog.c_cpu = id % mp_ncpus; } init_qset_cntxt(q, id); q->idx = id; @@ -2888,7 +2909,7 @@ check_ring_db(adapter_t *adap, struct sg * on this queue. If the system is under memory shortage use a fairly * long delay to help recovery. */ -int +static int process_responses(adapter_t *adap, struct sge_qset *qs, int budget) { struct sge_rspq *rspq = &qs->rspq; Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h Sat Jun 6 22:20:41 2009 (r193597) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h Sun Jun 7 00:02:52 2009 (r193598) @@ -73,9 +73,9 @@ m_freem_list(struct mbuf *m) while (m != NULL) { #ifdef INVARIANTS - if ((m == (struct mbuf *)0xDEADCODE) || + if ((m == (struct mbuf *)0xDEADC0DE) || m == (struct mbuf *)0xdeadc0dedeadc0de) - panic("freed mbuf %d in mbuf list", i); + panic("%s freed mbuf %d in mbuf list", __FUNCTION__, i); i++; #endif n = m->m_nextpkt;