diff options
author | jhb <jhb@FreeBSD.org> | 2016-11-04 03:25:34 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-11-04 03:25:34 +0000 |
commit | f610c349e74b68e20c4540d76819a2e516184df5 (patch) | |
tree | c008887d93bcbb62055d29046051c9ea238bec95 | |
parent | 2d04f6667f371a115b6d5ac43f04c2d2aa2418e6 (diff) | |
download | FreeBSD-src-f610c349e74b68e20c4540d76819a2e516184df5.zip FreeBSD-src-f610c349e74b68e20c4540d76819a2e516184df5.tar.gz |
MFC 277763,280146,287631: Various fixes to DDP.
277763:
Lock the socket buffer before jumping to the 'out' label if sblock()
fails in t4_soreceive_ddp().
280146:
Move special DDP handling for closing a connection into a new
handle_ddp_close() function in t4_ddp.c as the logic is similar
to handle_ddp_data(). This allows all knowledge of the special
DDP mbufs to be private to t4_ddp.c as well.
287631:
Add a comment to clarify how to determine the amount of received DDP
data.
Sponsored by: Chelsio Communications
-rw-r--r-- | sys/dev/cxgbe/tom/t4_cpl_io.c | 14 | ||||
-rw-r--r-- | sys/dev/cxgbe/tom/t4_ddp.c | 50 | ||||
-rw-r--r-- | sys/dev/cxgbe/tom/t4_tom.h | 3 |
3 files changed, 51 insertions, 16 deletions
diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index f1ac76e..c553f42 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -1102,19 +1102,7 @@ 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 = 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, - ("%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 -= m->m_len; /* adjust for F_RX_FC_DDP */ -#endif - sbappendstream_locked(sb, m); - toep->sb_cc = sb->sb_cc; + handle_ddp_close(toep, tp, sb, cpl->rcv_nxt); } socantrcvmore_locked(so); /* unlocks the sockbuf */ diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index 68ec2cc..90d646a 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -72,6 +72,8 @@ VNET_DECLARE(int, tcp_autorcvbuf_inc); VNET_DECLARE(int, tcp_autorcvbuf_max); #define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max) +static struct mbuf *get_ddp_mbuf(int len); + #define PPOD_SZ(n) ((n) * sizeof(struct pagepod)) #define PPOD_SIZE (PPOD_SZ(1)) @@ -403,6 +405,19 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report, __be32 rcv_nxt, int len) } tp = intotcpcb(inp); + + /* + * For RX_DDP_COMPLETE, len will be zero and rcv_nxt is the + * sequence number of the next byte to receive. The length of + * the data received for this message must be computed by + * comparing the new and old values of rcv_nxt. + * + * For RX_DATA_DDP, len might be non-zero, but it is only the + * length of the most recent DMA. It does not include the + * total length of the data received since the previous update + * for this DDP buffer. rcv_nxt is the sequence number of the + * first received byte from the most recent DMA. + */ len += be32toh(rcv_nxt) - tp->rcv_nxt; tp->rcv_nxt += len; tp->t_rcvtime = ticks; @@ -454,6 +469,37 @@ wakeup: return (0); } +void +handle_ddp_close(struct toepcb *toep, struct tcpcb *tp, struct sockbuf *sb, + __be32 rcv_nxt) +{ + struct mbuf *m; + int len; + + SOCKBUF_LOCK_ASSERT(sb); + INP_WLOCK_ASSERT(toep->inp); + len = be32toh(rcv_nxt) - tp->rcv_nxt; + + /* Signal handle_ddp() to break out of its sleep loop. */ + toep->ddp_flags &= ~(DDP_BUF0_ACTIVE | DDP_BUF1_ACTIVE); + if (len == 0) + return; + + tp->rcv_nxt += len; + 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 -= len; /* adjust for F_RX_FC_DDP */ +#endif + + m = get_ddp_mbuf(len); + + sbappendstream_locked(sb, m); + toep->sb_cc = sb->sb_cc; +} + #define DDP_ERR (F_DDP_PPOD_MISMATCH | F_DDP_LLIMIT_ERR | F_DDP_ULIMIT_ERR |\ F_DDP_PPOD_PARITY_ERR | F_DDP_PADDING_ERR | F_DDP_OFFSET_ERR |\ F_DDP_INVALID_TAG | F_DDP_COLOR_ERR | F_DDP_TID_MISMATCH |\ @@ -991,7 +1037,7 @@ soreceive_rcvoob(struct socket *so, struct uio *uio, int flags) static char ddp_magic_str[] = "nothing to see here"; -struct mbuf * +static struct mbuf * get_ddp_mbuf(int len) { struct mbuf *m; @@ -1078,9 +1124,9 @@ t4_soreceive_ddp(struct socket *so, struct sockaddr **psa, struct uio *uio, /* Prevent other readers from entering the socket. */ error = sblock(sb, SBLOCKWAIT(flags)); + SOCKBUF_LOCK(sb); if (error) goto out; - SOCKBUF_LOCK(sb); /* Easy one, no space to copyout anything. */ if (uio->uio_resid == 0) { diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index cc5d3b4..f24e147 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -281,9 +281,10 @@ 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 handle_ddp_close(struct toepcb *, struct tcpcb *, struct sockbuf *, + uint32_t); void insert_ddp_data(struct toepcb *, uint32_t); /* ULP related */ |