PERFORCE change 135021 for review

Kip Macy kmacy at FreeBSD.org
Fri Feb 8 00:09:04 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=135021

Change 135021 by kmacy at kmacy:storage:toehead on 2008/02/08 08:08:30

	log tom related events to KTR to isolate issue in DDP
	strengthen sockbuf locking assertions around ddp state

Affected files ...

.. //depot/projects/toehead/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#16 edit
.. //depot/projects/toehead/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#7 edit
.. //depot/projects/toehead/sys/dev/cxgb/ulp/tom/cxgb_defs.h#6 edit

Differences ...

==== //depot/projects/toehead/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#16 (text+ko) ====

@@ -35,6 +35,7 @@
 #include <sys/fcntl.h>
 #include <sys/kernel.h>
 #include <sys/limits.h>
+#include <sys/ktr.h>
 #include <sys/lock.h>
 #include <sys/mbuf.h>
 #include <sys/mutex.h>
@@ -84,8 +85,6 @@
 #include <dev/cxgb/ulp/tom/cxgb_toepcb.h>
 #include <dev/cxgb/ulp/tom/cxgb_tcp.h>
 
-
-
 /*
  * For ULP connections HW may add headers, e.g., for digests, that aren't part
  * of the messages sent by the host but that are part of the TCP payload and
@@ -151,7 +150,6 @@
 #define cxgb_tcp_drop	tcp_drop
 #endif
 
-
 static inline void
 SBAPPEND(struct sockbuf *sb, struct mbuf *n)
 {
@@ -318,9 +316,7 @@
 	}
 
 	INP_LOCK_ASSERT(tp->t_inpcb);
-	
 	SOCKBUF_LOCK(&so->so_snd);
-	
 	d = TOM_DATA(TOE_DEV(so));
 	cdev = d->cdev;
 	last = tail = so->so_snd.sb_sndptr ? so->so_snd.sb_sndptr : so->so_snd.sb_mb;
@@ -645,10 +641,14 @@
 	toep->tp_enqueued_bytes = so->so_rcv.sb_cc;
 	SOCKBUF_UNLOCK(&so->so_rcv);
 
-	if (credits > so->so_rcv.sb_mbmax)
+	if (credits > so->so_rcv.sb_mbmax) {
 	    printf("copied_seq=%u rcv_wup=%u credits=%u\n",
 		toep->tp_copied_seq, toep->tp_rcv_wup, credits);
-	/*
+	    credits = so->so_rcv.sb_mbmax;
+	}
+	
+	    
+	    /*
 	 * XXX this won't accurately reflect credit return - we need
 	 * to look at the difference between the amount that has been 
 	 * put in the recv sockbuf and what is there now
@@ -775,6 +775,9 @@
 {
 	struct cpl_set_tcb_field *req;
 
+	CTR4(KTR_TOM, "__set_tcb_field_ulp(tid=%u word=0x%x mask=%jx val=%jx",
+	    toep->tp_tid, word, mask, val);
+
 	req = mtod(m, struct cpl_set_tcb_field *);
 	m->m_pkthdr.len = m->m_len = sizeof(*req);
 	req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
@@ -799,10 +802,12 @@
 	
 	if (toep == NULL)
 		return;
-
-	if (tp->t_state == TCPS_CLOSED || (toep->tp_flags & TP_ABORT_SHUTDOWN))
+ 
+	if (tp->t_state == TCPS_CLOSED || (toep->tp_flags & TP_ABORT_SHUTDOWN)) {
+		printf("not seting field\n");
 		return;
-
+	}
+	
 	m = m_gethdr_nofail(sizeof(struct cpl_set_tcb_field));
 
 	__set_tcb_field(toep, m, word, mask, val, 1);
@@ -873,10 +878,11 @@
 static void
 t3_enable_ddp(struct socket *so, int on)
 {
-	if (on)
+	if (on) {
+		
 		t3_set_tcb_field(so, W_TCB_RX_DDP_FLAGS, V_TF_DDP_OFF(1),
 				 V_TF_DDP_OFF(0));
-	else
+	} else
 		t3_set_tcb_field(so, W_TCB_RX_DDP_FLAGS,
 				 V_TF_DDP_OFF(1) |
 				 TP_DDP_TIMER_WORKAROUND_MASK,
@@ -1663,6 +1669,7 @@
 	__be64 *tcb;
 
 	so = toeptoso(toep);
+	tp = toep->tp_tp;
 	SOCKBUF_LOCK(&so->so_rcv);
 	
 	/* Note that we only accout for CPL_GET_TCB issued by the DDP code. We
@@ -1703,7 +1710,9 @@
 		  "tcb_rpl_as_ddp_complete: seq 0x%x hwbuf %u ddp_offset %u",
 		  tp->rcv_nxt, q->cur_buf, ddp_offset);
 #endif
-
+	CTR3(KTR_TOM, "tcb_rpl_as_ddp_complete(seq=0x%x hwbuf=%u ddp_offset=%u",
+		  tp->rcv_nxt, q->cur_buf, ddp_offset);
+	
 #if 0
 {
 	unsigned int ddp_flags, rcv_nxt, rx_hdr_offset, buf_idx;
@@ -1794,7 +1803,6 @@
 	}
 
 	KASSERT(m->m_len > 0, ("%s m_len=%d", __FUNCTION__, m->m_len));
-	tp = toep->tp_tp;
 	m->m_ddp_gl = (unsigned char *)bsp->gl;
 	m->m_flags |= M_DDP;
 	m->m_seq = tp->rcv_nxt;
@@ -1809,6 +1817,8 @@
 		  "tcb_rpl_as_ddp_complete: seq 0x%x hwbuf %u lskb->len %u",
 		  m->m_seq, q->cur_buf, m->m_pkthdr.len);
 #endif
+	CTR3(KTR_TOM, "tcb_rpl_as_ddp_complete: seq 0x%x hwbuf %u m->m_pktlen %u",
+		  m->m_seq, q->cur_buf, m->m_pkthdr.len);
 	SBAPPEND(&so->so_rcv, m);
 	if (__predict_true((so->so_state & SS_NOFDREF) == 0))
 		sorwakeup_locked(so);
@@ -2170,7 +2180,12 @@
 		  tp->rcv_nxt, bsp->cur_offset, ddp_report,
 		   G_DDP_OFFSET(ddp_report), skb->len);
 #endif
-
+	CTR5(KTR_TOM,
+		  "process_ddp_complete: tp->rcv_nxt 0x%x cur_offset %u "
+		  "ddp_report 0x%x offset %u, len %u",
+		  tp->rcv_nxt, bsp->cur_offset, ddp_report,
+		   G_DDP_OFFSET(ddp_report), m->m_len);
+	
 	bsp->cur_offset += m->m_len;
 
 	if (!(bsp->flags & DDP_BF_NOFLIP)) {
@@ -2186,6 +2201,12 @@
 		  tp->rcv_nxt, bsp->cur_offset, ddp_report,
 		   G_DDP_OFFSET(ddp_report));
 #endif
+	CTR4(KTR_TOM,
+		  "process_ddp_complete: tp->rcv_nxt 0x%x cur_offset %u "
+		  "ddp_report %u offset %u",
+		  tp->rcv_nxt, bsp->cur_offset, ddp_report,
+		   G_DDP_OFFSET(ddp_report));
+	
 	m->m_ddp_gl = (unsigned char *)bsp->gl;
 	m->m_flags |= M_DDP;
 	m->m_ddp_flags = (bsp->flags & DDP_BF_NOCOPY) | 1;
@@ -3216,30 +3237,20 @@
 	DPRINTF("opt0l_status=%08x\n", rpl->opt0l_status);
 	
 	m_set_priority(reply_mbuf, mkprio(CPL_PRIORITY_SETUP, newtoep));
-#ifdef DEBUG_PRINT		
-	{
-		int i;
-
-		DPRINTF("rpl:\n");
-		uint32_t *rplbuf = mtod(reply_mbuf, uint32_t *);
 		
-		for (i = 0; i < sizeof(*rpl)/sizeof(uint32_t); i++)
-			DPRINTF("[%d] %08x\n", i, rplbuf[i]);
-	}
-#endif	
-
-		
 	l2t_send(cdev, reply_mbuf, e);
 	m_free(m);
-	/*
-	 * XXX this call path has to be converted to not depend on sockets
-	 */
-	if (newtoep->tp_ulp_mode) 
+	if (newtoep->tp_ulp_mode) {	
+		printf("setting ulp mode to DDP\n");
 		__set_tcb_field(newtoep, ddp_mbuf, W_TCB_RX_DDP_FLAGS,
 				V_TF_DDP_OFF(1) |
 				TP_DDP_TIMER_WORKAROUND_MASK,
 				V_TF_DDP_OFF(1) |
-				TP_DDP_TIMER_WORKAROUND_VAL, 1);
+		    TP_DDP_TIMER_WORKAROUND_VAL, 1);
+	} else
+		printf("not offloading\n");
+	
+	
 
 	return;
 reject:
@@ -3849,6 +3860,9 @@
 	unsigned int tid = toep->tp_tid;
 	const struct tom_data *td = TOM_DATA(TOE_DEV(so));
 	unsigned int ppod_addr = tag * PPOD_SIZE + td->ddp_llimit;
+
+	CTR6(KTR_TOM, "t3_setup_ppods(gl=%p nppods=%u tag=%u maxoff=%u pg_off=%u color=%u)",
+	    gl, nppods, tag, maxoff, pg_off, color);
 	
 	for (i = 0; i < nppods; ++i) {
 		m = m_gethdr_nofail(sizeof(*req) + PPOD_SIZE);
@@ -3917,7 +3931,10 @@
                      unsigned int word, uint64_t mask, uint64_t val)
 {
 	struct ulp_txpkt *txpkt = (struct ulp_txpkt *)req;
-
+	
+	CTR4(KTR_TOM, "mk_set_tcb_field_ulp(tid=%u word=0x%x mask=%jx val=%jx",
+	    tid, word, mask, val);
+	
 	txpkt->cmd_dest = htonl(V_ULPTX_CMD(ULP_TXPKT));
 	txpkt->len = htonl(V_ULPTX_NFLITS(sizeof(*req) / 8));
 	OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, tid));
@@ -3970,6 +3987,9 @@
 
 	req = (struct cpl_set_tcb_field *)(lock + 1);
 
+	CTR1(KTR_TOM, "t3_cancel_ddpbuf(bufidx=%u)",
+	    bufidx);
+
 	/* Hmmm, not sure if this actually a good thing: reactivating
 	 * the other buffer might be an issue if it has been completed
 	 * already. However, that is unlikely, since the fact that the UBUF
@@ -4028,6 +4048,8 @@
 	struct cpl_set_tcb_field *req;
 	struct ddp_state *p = &toep->tp_ddp_state;
 
+	CTR4(KTR_TOM, "t3_setup_ppods(bufidx=%u tag0=%u tag1=%u len=%u)",
+	    bufidx, tag0, tag1, len);
 	SOCKBUF_LOCK_ASSERT(&toeptoso(toep)->so_rcv);
 	wrlen = sizeof(*wr) + 3 * sizeof(*req) + sizeof(*getreq);
 	m = m_gethdr_nofail(wrlen);
@@ -4101,6 +4123,9 @@
 	struct work_request_hdr *wr;
 	struct cpl_set_tcb_field *req;
 
+	CTR6(KTR_TOM, "t3_setup_ddpbufs(len0=%u offset0=%u len1=%u offset1=%u ddp_flags=0x%08x%08x ",
+	    len0, offset0, len1, offset1, ddp_flags >> 32, ddp_flags & 0xffffffff);
+	
 	SOCKBUF_LOCK_ASSERT(&toeptoso(toep)->so_rcv);
 	wrlen = sizeof(*wr) + sizeof(*req) + (len0 ? sizeof(*req) : 0) +
 		(len1 ? sizeof(*req) : 0) +

==== //depot/projects/toehead/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#7 (text+ko) ====

@@ -35,6 +35,7 @@
 #include <sys/types.h>
 #include <sys/fcntl.h>
 #include <sys/kernel.h>
+#include <sys/ktr.h>
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/mbuf.h>
@@ -134,7 +135,7 @@
 	pg_off = addr & PAGE_MASK;
 	npages = (pg_off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	p = malloc(sizeof(struct ddp_gather_list) + npages * sizeof(vm_page_t *),
-	    M_DEVBUF, M_NOWAIT);
+	    M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (p == NULL)
 		return (ENOMEM);
 
@@ -229,6 +230,7 @@
 	int err, tag, npages, nppods;
 	struct tom_data *d = TOM_DATA(TOE_DEV(so));
 
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);
 	npages = ((addr & PAGE_MASK) + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	nppods = min(pages2ppods(npages), MAX_PPODS);
 	nppods = roundup2(nppods, PPOD_CLUSTER_SIZE);
@@ -262,7 +264,8 @@
 {
 	struct toepcb *toep = sototcpcb(so)->t_toe;
 	struct ddp_state *p = &toep->tp_ddp_state;
-	
+
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);
 	p->buf_state[bufidx].cur_offset = p->kbuf[bufidx]->dgl_offset;
 	p->buf_state[bufidx].flags = p->kbuf_noinval ? DDP_BF_NOINVAL : 0;
 	p->buf_state[bufidx].gl = p->kbuf[bufidx];
@@ -340,6 +343,7 @@
 	struct iovec *iov = uio->uio_iov;
 	vm_offset_t addr = (vm_offset_t)iov->iov_base - oft;
 
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);
 	if (__predict_false(p->ubuf_nppods == 0)) {
 		err = alloc_buf1_ppods(so, p, addr, iov->iov_len + oft);
 		if (err)
@@ -385,6 +389,7 @@
 	if (p->ubuf == NULL)
 		return;
 
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);	
 	p->cancel_ubuf = 1;
 	while (ubuf_pending && !(so->so_state & (SS_ISDISCONNECTING|SS_ISDISCONNECTED))) {
 #ifdef T3_TRACE
@@ -394,6 +399,11 @@
 		  p->buf_state[1].flags & (DDP_BF_NOFLIP | DDP_BF_NOCOPY),
 		  p->get_tcb_count);
 #endif
+		CTR3(KTR_TOM,
+		  "t3_cancel_ubuf: flags0 0x%x flags1 0x%x get_tcb_count %d",
+		  p->buf_state[0].flags & (DDP_BF_NOFLIP | DDP_BF_NOCOPY), 
+		  p->buf_state[1].flags & (DDP_BF_NOFLIP | DDP_BF_NOCOPY),
+		  p->get_tcb_count);	
 		if (p->get_tcb_count == 0)
 			t3_cancel_ddpbuf(toep, p->cur_buf);
 		else {
@@ -401,9 +411,9 @@
 			timeo = so->so_rcv.sb_timeo;
 			flags = so->so_rcv.sb_flags;
 			
-			so->so_rcv.sb_timeo = 3*hz;
+			so->so_rcv.sb_timeo = 30*hz;
 			while (p->get_tcb_count && !(so->so_state & (SS_ISDISCONNECTING|SS_ISDISCONNECTED))) {
-				if (count & 0xff)
+				if (count & 0xffffff)
 					printf("waiting err=%d get_tcb_count=%d timeo=%d so=%p\n",
 					    err, p->get_tcb_count, so->so_rcv.sb_timeo, so);
 				count++;
@@ -441,6 +451,7 @@
 		return (EINVAL);
 	}
 	
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);
 	err = setup_uio_ppods(so, uio, 0, &len);
 	if (err) {
 		return (err);
@@ -485,6 +496,10 @@
 		  " kbuf_idx %d",
 		   p->ubuf_tag, flags, OVERLAY_MASK, ubuf_idx, p->kbuf_idx);
 #endif
+	CTR5(KTR_TOM,
+		  "t3_overlay_ubuf: tag %u flags 0x%x mask 0x%x ubuf_idx %d "
+		  " kbuf_idx %d",
+		   p->ubuf_tag, flags, OVERLAY_MASK, ubuf_idx, p->kbuf_idx);	
 	return (0);
 }
 
@@ -555,6 +570,8 @@
 	T3_TRACE1(TIDTB(so),
 		  "t3_post_kbuf: cur_buf = kbuf_idx = %u ", p->cur_buf);
 #endif
+	CTR1(KTR_TOM,
+		  "t3_post_kbuf: cur_buf = kbuf_idx = %u ", p->cur_buf);
 }
 
 /*
@@ -571,9 +588,11 @@
 	struct ddp_state *p = &toep->tp_ddp_state;
 	struct tom_data *d = TOM_DATA(toep->tp_toedev);
 
+	
 	if (kbuf_size > M_TCB_RX_DDP_BUF0_LEN)
 		return (EINVAL);
 
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);
 	nonblock = (so->so_state & SS_NBIO);
 	
 	kbuf_pages = (kbuf_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -617,22 +636,25 @@
 			p->kbuf[idx]->phys_addr[i] = 
 			    pci_map_page(p->pdev, p->kbuf[idx]->pages[i],
 					 0, PAGE_SIZE, PCI_DMA_FROMDEVICE);
-#endif		
+#endif
 		t3_setup_ppods(so, p->kbuf[idx], nppods, p->kbuf_tag[idx], 
 			       p->kbuf[idx]->dgl_length, 0, 0);
 	}
 	t3_set_ddp_tag(so, 0, p->kbuf_tag[0] << 6);
 	t3_set_ddp_buf(so, 0, 0, p->kbuf[0]->dgl_length);
 	t3_repost_kbuf(so, 0, 0, 1, nonblock);
+
 	t3_set_rcv_coalesce_enable(so, 
 	    TOM_TUNABLE(TOE_DEV(so), ddp_rcvcoalesce));
 
-	printf("ddp entered\n");
 #ifdef T3_TRACE
 	T3_TRACE4(TIDTB(so),
 		  "t3_enter_ddp: kbuf_size %u waitall %u tag0 %d tag1 %d",
 		   kbuf_size, waitall, p->kbuf_tag[0], p->kbuf_tag[1]);
 #endif
+	CTR4(KTR_TOM,
+		  "t3_enter_ddp: kbuf_size %u waitall %u tag0 %d tag1 %d",
+		   kbuf_size, waitall, p->kbuf_tag[0], p->kbuf_tag[1]);
 
 	return (0);
 
@@ -686,6 +708,8 @@
 			}
 		memset(&td->ppod_map[i], 1, n);   /* allocate range */
 		mtx_unlock(&td->ppod_map_lock);
+		CTR2(KTR_TOM,
+		    "t3_alloc_ppods: n=%u tag=%u", n, i);
 		*ptag = i;
 		return (0);
 	next: ;

==== //depot/projects/toehead/sys/dev/cxgb/ulp/tom/cxgb_defs.h#6 (text+ko) ====

@@ -43,7 +43,7 @@
 #define TRACE_ENTER printf("%s:%s entered\n", __FUNCTION__, __FILE__)
 #define TRACE_EXIT printf("%s:%s:%d exited\n", __FUNCTION__, __FILE__, __LINE__)
 	
-
+#define	KTR_TOM	KTR_SPARE2
 
 struct toepcb;
 struct listen_ctx;


More information about the p4-projects mailing list