diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 5f3861e8a13d..fa45b6bb1381 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -827,15 +827,8 @@ do_peer_close(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) 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, diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index 5e0120f23981..d8505c25e6fb 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -217,13 +217,7 @@ insert_ddp_data(struct toepcb *toep, uint32_t n) 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, __be32 ddp_report, __be32 rcv_nxt, int len) 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, struct uio *uio, int flags) 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 mbuf *m, int len) 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; diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index 4c45616a1b18..fb4584ce6055 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -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 *, struct tom_data *); 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);