From owner-p4-projects@FreeBSD.ORG Fri Feb 22 00:29:25 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 20BB916A40B; Fri, 22 Feb 2008 00:29:25 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C174F16A407 for ; Fri, 22 Feb 2008 00:29:24 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id AF79913C457 for ; Fri, 22 Feb 2008 00:29:24 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m1M0TOIX008029 for ; Fri, 22 Feb 2008 00:29:24 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m1M0TOZ4008026 for perforce@freebsd.org; Fri, 22 Feb 2008 00:29:24 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 22 Feb 2008 00:29:24 GMT Message-Id: <200802220029.m1M0TOZ4008026@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 135929 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2008 00:29:25 -0000 http://perforce.freebsd.org/chv.cgi?CH=135929 Change 135929 by kmacy@kmacy:entropy:iwarp on 2008/02/22 00:28:30 we were treating the number of descriptors used as 0 when using TX_MAX_SEGS fix Affected files ... .. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#16 edit Differences ... ==== //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#16 (text+ko) ==== @@ -117,7 +117,7 @@ * in the skb and whether it has any payload in its main body. This maps the * length of the gather list represented by an skb into the # of necessary WRs. */ -static unsigned int mbuf_wrs[TX_MAX_SEGS] __read_mostly; +static unsigned int mbuf_wrs[TX_MAX_SEGS + 1] __read_mostly; /* * Max receive window supported by HW in bytes. Only a small part of it can @@ -358,10 +358,10 @@ KASSERT(!m0->m_next, ("bad append")); } else { while ((mbuf_wrs[count + 1] <= toep->tp_wr_avail) - && (tail != NULL) && (count < TX_MAX_SEGS)) { + && (tail != NULL) && (count < TX_MAX_SEGS-1)) { bytes += tail->m_len; + last = tail; count++; - last = tail; /* * technically an abuse to be using this for a VA * but less gross than defining my own structure @@ -371,7 +371,6 @@ segp->ds_len = tail->m_len; DPRINTF("count=%d wr_needed=%d ds_addr=%p ds_len=%d\n", count, mbuf_wrs[count], tail->m_data, tail->m_len); - segp++; tail = tail->m_next; } @@ -405,8 +404,6 @@ CTR3(KTR_TOM, "t3_push_frames: total_bytes=%d tp_m_last=%p snd_una=0x%08x", total_bytes, toep->tp_m_last, tp->snd_una); - toep->tp_wr_avail -= mbuf_wrs[count]; - toep->tp_wr_unacked += mbuf_wrs[count]; i = 0; while (i < count && m_get_sgllen(m0)) { @@ -434,6 +431,9 @@ */ m0->m_pkthdr.csum_data = mbuf_wrs[count]; m0->m_pkthdr.len = bytes; + toep->tp_wr_avail -= mbuf_wrs[count]; + toep->tp_wr_unacked += mbuf_wrs[count]; + if ((req_completion && toep->tp_wr_unacked == mbuf_wrs[count]) || toep->tp_wr_unacked >= toep->tp_wr_max / 2) { struct work_request_hdr *wr = cplhdr(m0); @@ -441,7 +441,9 @@ wr->wr_hi |= htonl(F_WR_COMPL); toep->tp_wr_unacked = 0; } - + KASSERT((m0->m_pkthdr.csum_data > 0) && + (m0->m_pkthdr.csum_data <= 4), ("bad credit count %d", + m0->m_pkthdr.csum_data)); m0->m_type = MT_DONTFREE; enqueue_wr(toep, m0); DPRINTF("sending offload tx with %d bytes in %d segments\n", @@ -3736,16 +3738,19 @@ while (credits) { struct mbuf *p = peek_wr(toep); - CTR2(KTR_TOM, - "wr_ack: p->credits=%d p->bytes=%d", p->m_pkthdr.csum_data, p->m_pkthdr.len); if (__predict_false(!p)) { log(LOG_ERR, "%u WR_ACK credits for TID %u with " - "nothing pending, state %u\n", - credits, toep->tp_tid, tp->t_state); + "nothing pending, state %u wr_avail=%u\n", + credits, toep->tp_tid, tp->t_state, toep->tp_wr_avail); break; } + CTR2(KTR_TOM, + "wr_ack: p->credits=%d p->bytes=%d", p->m_pkthdr.csum_data, p->m_pkthdr.len); + + KASSERT(p->m_pkthdr.csum_data != 0, ("empty request still on list")); if (__predict_false(credits < p->m_pkthdr.csum_data)) { + #if DEBUG_WR > 1 struct tx_data_wr *w = cplhdr(p); log(LOG_ERR, @@ -3763,7 +3768,9 @@ dequeue_wr(toep); credits -= p->m_pkthdr.csum_data; bytes += p->m_pkthdr.len; - DPRINTF("done with wr of %d bytes\n", p->m_pkthdr.len); + CTR3(KTR_TOM, + "wr_ack: done with wr of %d bytes remain credits=%d wr credits=%d", + p->m_pkthdr.len, credits, p->m_pkthdr.csum_data); m_free(p); }