Author: jhb
Date: Mon Mar 16 15:56:06 2015
New Revision: 280146
URL: https://svnweb.freebsd.org/changeset/base/280146

Log:
  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.

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  Mon Mar 16 15:54:53 2015        
(r280145)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Mon Mar 16 15:56:06 2015        
(r280146)
@@ -1105,19 +1105,7 @@ 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 = 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 >= sbused(sb),
-                   ("%s: sb %p has more data (%d) than last time (%d).",
-                   __func__, sb, sbused(sb), toep->sb_cc));
-               toep->rx_credits += toep->sb_cc - sbused(sb);
-#ifdef USE_DDP_RX_FLOW_CONTROL
-               toep->rx_credits -= m->m_len;   /* adjust for F_RX_FC_DDP */
-#endif
-               sbappendstream_locked(sb, m, 0);
-               toep->sb_cc = sbused(sb);
+               handle_ddp_close(toep, tp, sb, cpl->rcv_nxt);
        }
        socantrcvmore_locked(so);       /* unlocks the sockbuf */
 

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_ddp.c     Mon Mar 16 15:54:53 2015        
(r280145)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c     Mon Mar 16 15:56:06 2015        
(r280146)
@@ -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))
 
@@ -454,6 +456,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 >= sbused(sb),
+           ("%s: sb %p has more data (%d) than last time (%d).",
+           __func__, sb, sbused(sb), toep->sb_cc));
+       toep->rx_credits += toep->sb_cc - sbused(sb);
+#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, 0);
+       toep->sb_cc = sbused(sb);
+}
+
 #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 |\
@@ -992,7 +1025,7 @@ soreceive_rcvoob(struct socket *so, stru
 
 static char ddp_magic_str[] = "nothing to see here";
 
-struct mbuf *
+static struct mbuf *
 get_ddp_mbuf(int len)
 {
        struct mbuf *m;

Modified: head/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.h     Mon Mar 16 15:54:53 2015        
(r280145)
+++ head/sys/dev/cxgbe/tom/t4_tom.h     Mon Mar 16 15:56:06 2015        
(r280146)
@@ -281,9 +281,10 @@ 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 handle_ddp_close(struct toepcb *, struct tcpcb *, struct sockbuf *,
+    uint32_t);
 void insert_ddp_data(struct toepcb *, uint32_t);
 
 /* ULP related */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to