From owner-svn-src-head@FreeBSD.ORG Fri May 3 18:37:51 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 21D40EB1; Fri, 3 May 2013 18:37:51 +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 12FEA1BF6; Fri, 3 May 2013 18:37:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r43IboiW083482; Fri, 3 May 2013 18:37:50 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r43Iboth083479; Fri, 3 May 2013 18:37:50 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201305031837.r43Iboth083479@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 3 May 2013 18:37:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250218 - 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: Fri, 03 May 2013 18:37:51 -0000 Author: np Date: Fri May 3 18:37:50 2013 New Revision: 250218 URL: http://svnweb.freebsd.org/changeset/base/250218 Log: cxgbe/tom: Do not use M_PROTO1 to mark rx zero-copy mbufs as special. All the M_PROTOn flags are clobbered when an mbuf is appended to the socket buffer. 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 Fri May 3 16:29:51 2013 (r250217) +++ head/sys/dev/cxgbe/tom/t4_cpl_io.c Fri May 3 18:37:50 2013 (r250218) @@ -827,15 +827,8 @@ do_peer_close(struct sge_iq *iq, const s sb = &so->so_rcv; SOCKBUF_LOCK(sb); if (__predict_false(toep->ddp_flags & (DDP_BUF0_ACTIVE | DDP_BUF1_ACTIVE))) { - m = m_get(M_NOWAIT, MT_DATA); - if (m == NULL) - CXGBE_UNIMPLEMENTED("mbuf alloc failure"); - - m->m_len = be32toh(cpl->rcv_nxt) - tp->rcv_nxt; - m->m_flags |= M_DDP; /* Data is already where it should be */ - m->m_data = "nothing to see here"; + m = get_ddp_mbuf(be32toh(cpl->rcv_nxt) - tp->rcv_nxt); tp->rcv_nxt = be32toh(cpl->rcv_nxt); - toep->ddp_flags &= ~(DDP_BUF0_ACTIVE | DDP_BUF1_ACTIVE); KASSERT(toep->sb_cc >= sb->sb_cc, Modified: head/sys/dev/cxgbe/tom/t4_ddp.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_ddp.c Fri May 3 16:29:51 2013 (r250217) +++ head/sys/dev/cxgbe/tom/t4_ddp.c Fri May 3 18:37:50 2013 (r250218) @@ -217,13 +217,7 @@ insert_ddp_data(struct toepcb *toep, uin 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"; - + m = get_ddp_mbuf(n); tp->rcv_nxt += n; #ifndef USE_DDP_RX_FLOW_CONTROL KASSERT(tp->rcv_wnd >= n, ("%s: negative window size", __func__)); @@ -457,13 +451,7 @@ handle_ddp_data(struct toepcb *toep, __b KASSERT(tp->rcv_wnd >= len, ("%s: negative window size", __func__)); tp->rcv_wnd -= len; #endif - - m = m_get(M_NOWAIT, MT_DATA); - if (m == NULL) - CXGBE_UNIMPLEMENTED("mbuf alloc failure"); - m->m_len = len; - m->m_flags |= M_DDP; /* Data is already where it should be */ - m->m_data = "nothing to see here"; + m = get_ddp_mbuf(len); SOCKBUF_LOCK(sb); if (report & F_DDP_BUF_COMPLETE) @@ -1022,6 +1010,29 @@ soreceive_rcvoob(struct socket *so, stru CXGBE_UNIMPLEMENTED(__func__); } +static char ddp_magic_str[] = "nothing to see here"; + +struct mbuf * +get_ddp_mbuf(int len) +{ + struct mbuf *m; + + m = m_get(M_NOWAIT, MT_DATA); + if (m == NULL) + CXGBE_UNIMPLEMENTED("mbuf alloc failure"); + m->m_len = len; + m->m_data = &ddp_magic_str[0]; + + return (m); +} + +static inline int +is_ddp_mbuf(struct mbuf *m) +{ + + return (m->m_data == &ddp_magic_str[0]); +} + /* * Copy an mbuf chain into a uio limited by len if set. */ @@ -1040,7 +1051,7 @@ m_mbuftouio_ddp(struct uio *uio, struct for (; m != NULL; m = m->m_next) { length = min(m->m_len, total - progress); - if (m->m_flags & M_DDP) { + if (is_ddp_mbuf(m)) { enum uio_seg segflag = uio->uio_segflg; uio->uio_segflg = UIO_NOCOPY; Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Fri May 3 16:29:51 2013 (r250217) +++ head/sys/dev/cxgbe/tom/t4_tom.h Fri May 3 18:37:50 2013 (r250218) @@ -49,8 +49,6 @@ #define DDP_RSVD_WIN (16 * 1024U) #define SB_DDP_INDICATE SB_IN_TOE /* soreceive must respond to indicate */ -#define M_DDP M_PROTO1 - #define USE_DDP_RX_FLOW_CONTROL /* TOE PCB flags */ @@ -279,6 +277,7 @@ void t4_init_ddp(struct adapter *, struc void t4_uninit_ddp(struct adapter *, struct tom_data *); int t4_soreceive_ddp(struct socket *, struct sockaddr **, struct uio *, struct mbuf **, struct mbuf **, int *); +struct mbuf *get_ddp_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);