From owner-svn-src-head@FreeBSD.ORG Thu Nov 29 19:39:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0E30056A; Thu, 29 Nov 2012 19:39:28 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E83938FC17; Thu, 29 Nov 2012 19:39:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qATJdRtk043962; Thu, 29 Nov 2012 19:39:27 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qATJdR2v043959; Thu, 29 Nov 2012 19:39:27 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201211291939.qATJdR2v043959@svn.freebsd.org> From: Navdeep Parhar Date: Thu, 29 Nov 2012 19:39:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243681 - head/sys/dev/cxgbe/tom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2012 19:39:28 -0000 Author: np Date: Thu Nov 29 19:39:27 2012 New Revision: 243681 URL: http://svnweb.freebsd.org/changeset/base/243681 Log: cxgbe/tom: Handle the case where the chip falls out of DDP mode by itself. The hole in the receive sequence space corresponds to the number of bytes placed directly up to that point. MFC after: 1 week Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c head/sys/dev/cxgbe/tom/t4_ddp.c head/sys/dev/cxgbe/tom/t4_tom.h Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_cpl_io.c Thu Nov 29 19:10:04 2012 (r243680) +++ head/sys/dev/cxgbe/tom/t4_cpl_io.c Thu Nov 29 19:39:27 2012 (r243681) @@ -1113,6 +1113,7 @@ do_rx_data(struct sge_iq *iq, const stru struct socket *so; struct sockbuf *sb; int len; + uint32_t ddp_placed = 0; if (__predict_false(toep->flags & TPF_SYNQE)) { #ifdef INVARIANTS @@ -1154,13 +1155,8 @@ do_rx_data(struct sge_iq *iq, const stru tp = intotcpcb(inp); -#ifdef INVARIANTS - if (__predict_false(tp->rcv_nxt != be32toh(cpl->seq))) { - log(LOG_ERR, - "%s: unexpected seq# %x for TID %u, rcv_nxt %x\n", - __func__, be32toh(cpl->seq), toep->tid, tp->rcv_nxt); - } -#endif + if (__predict_false(tp->rcv_nxt != be32toh(cpl->seq))) + ddp_placed = be32toh(cpl->seq) - tp->rcv_nxt; tp->rcv_nxt += len; KASSERT(tp->rcv_wnd >= len, ("%s: negative window size", __func__)); @@ -1207,12 +1203,20 @@ do_rx_data(struct sge_iq *iq, const stru int changed = !(toep->ddp_flags & DDP_ON) ^ cpl->ddp_off; if (changed) { - if (__predict_false(!(toep->ddp_flags & DDP_SC_REQ))) { - /* XXX: handle this if legitimate */ - panic("%s: unexpected DDP state change %d", - __func__, cpl->ddp_off); + if (toep->ddp_flags & DDP_SC_REQ) + toep->ddp_flags ^= DDP_ON | DDP_SC_REQ; + else { + KASSERT(cpl->ddp_off == 1, + ("%s: DDP switched on by itself.", + __func__)); + + /* Fell out of DDP mode */ + toep->ddp_flags &= ~(DDP_ON | DDP_BUF0_ACTIVE | + DDP_BUF1_ACTIVE); + + if (ddp_placed) + insert_ddp_data(toep, ddp_placed); } - toep->ddp_flags ^= DDP_ON | DDP_SC_REQ; } if ((toep->ddp_flags & DDP_OK) == 0 && Modified: head/sys/dev/cxgbe/tom/t4_ddp.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_ddp.c Thu Nov 29 19:10:04 2012 (r243680) +++ head/sys/dev/cxgbe/tom/t4_ddp.c Thu Nov 29 19:39:27 2012 (r243681) @@ -205,6 +205,42 @@ release_ddp_resources(struct toepcb *toe } } +/* XXX: handle_ddp_data code duplication */ +void +insert_ddp_data(struct toepcb *toep, uint32_t n) +{ + struct inpcb *inp = toep->inp; + struct tcpcb *tp = intotcpcb(inp); + struct sockbuf *sb = &inp->inp_socket->so_rcv; + struct mbuf *m; + + INP_WLOCK_ASSERT(inp); + SOCKBUF_LOCK_ASSERT(sb); + + m = m_get(M_NOWAIT, MT_DATA); + if (m == NULL) + CXGBE_UNIMPLEMENTED("mbuf alloc failure"); + m->m_len = n; + m->m_flags |= M_DDP; /* Data is already where it should be */ + m->m_data = "nothing to see here"; + + tp->rcv_nxt += n; +#ifndef USE_DDP_RX_FLOW_CONTROL + KASSERT(tp->rcv_wnd >= n, ("%s: negative window size", __func__)); + tp->rcv_wnd -= n; +#endif + + KASSERT(toep->sb_cc >= sb->sb_cc, + ("%s: sb %p has more data (%d) than last time (%d).", + __func__, sb, sb->sb_cc, toep->sb_cc)); + toep->rx_credits += toep->sb_cc - sb->sb_cc; +#ifdef USE_DDP_RX_FLOW_CONTROL + toep->rx_credits -= n; /* adjust for F_RX_FC_DDP */ +#endif + sbappendstream_locked(sb, m); + toep->sb_cc = sb->sb_cc; +} + /* SET_TCB_FIELD sent as a ULP command looks like this */ #define LEN__SET_TCB_FIELD_ULP (sizeof(struct ulp_txpkt) + \ sizeof(struct ulptx_idata) + sizeof(struct cpl_set_tcb_field_core)) Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Thu Nov 29 19:10:04 2012 (r243680) +++ head/sys/dev/cxgbe/tom/t4_tom.h Thu Nov 29 19:39:27 2012 (r243681) @@ -273,4 +273,5 @@ int t4_soreceive_ddp(struct socket *, st struct mbuf **, struct mbuf **, int *); void enable_ddp(struct adapter *, struct toepcb *toep); void release_ddp_resources(struct toepcb *toep); +void insert_ddp_data(struct toepcb *, uint32_t); #endif