From owner-p4-projects@FreeBSD.ORG Fri Feb 8 20:06:20 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F28D616A468; Fri, 8 Feb 2008 20:06:19 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F74916A41B for ; Fri, 8 Feb 2008 20:06:19 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8961C13C4CE for ; Fri, 8 Feb 2008 20:06:19 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m18K6JrX094797 for ; Fri, 8 Feb 2008 20:06:19 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m18K6JsV094794 for perforce@freebsd.org; Fri, 8 Feb 2008 20:06:19 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 8 Feb 2008 20:06:19 GMT Message-Id: <200802082006.m18K6JsV094794@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 135046 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2008 20:06:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=135046 Change 135046 by kmacy@kmacy:entropy:iwarp on 2008/02/08 20:05:31 add logging, and asserts for DDP Affected files ... .. //depot/projects/iwarp/sys/amd64/conf/GENERIC#9 integrate .. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#10 integrate .. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#4 integrate .. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_defs.h#8 integrate .. //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_tom.c#7 integrate .. //depot/projects/iwarp/sys/modules/cxgb/tom/Makefile#5 integrate Differences ... ==== //depot/projects/iwarp/sys/amd64/conf/GENERIC#9 (text+ko) ==== @@ -26,6 +26,7 @@ makeoptions MODULES_OVERRIDE="cxgb em if_vlan linux linprocfs hwpmc netgraph" makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +makeoptions MODULES_OVERRIDE="cxgb em" options SCHED_ULE options IPI_PREEMPTION @@ -215,12 +216,13 @@ options ALT_BREAK_TO_DEBUGGER -options ALQ -options KTR_ALQ -options KTR_COMPILE=(KTR_SCHED) -options KTR_CPUMASK=0x3 -options KTR_ENTRIES=8192 -options KTR_MASK=(KTR_SCHED) -options KTR_VERBOSE +options KTR +#options ALQ +#options KTR_ALQ +options KTR_COMPILE=(KTR_SPARE2) +options KTR_CPUMASK=0x7 +options KTR_ENTRIES=65536 +options KTR_MASK=(KTR_SPARE2) +#options KTR_VERBOSE ==== //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#10 (text+ko) ==== @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -84,8 +85,6 @@ #include #include - - /* * 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) { @@ -319,9 +317,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; @@ -646,10 +642,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 @@ -776,6 +776,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)); @@ -800,10 +803,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); @@ -874,10 +879,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, @@ -1660,6 +1666,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 @@ -1700,7 +1707,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; @@ -1791,7 +1800,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; @@ -1806,6 +1814,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); @@ -2167,7 +2177,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)) { @@ -2183,6 +2198,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; @@ -3213,30 +3234,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: @@ -3846,6 +3857,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); @@ -3914,7 +3928,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)); @@ -3967,6 +3984,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 @@ -4025,6 +4045,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); @@ -4098,6 +4120,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/iwarp/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#4 (text+ko) ==== @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -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/iwarp/sys/dev/cxgb/ulp/tom/cxgb_defs.h#8 (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; ==== //depot/projects/iwarp/sys/dev/cxgb/ulp/tom/cxgb_tom.c#7 (text+ko) ==== @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -140,7 +141,7 @@ { struct toepcb *toep; - toep = malloc(sizeof(struct toepcb), M_DEVBUF, M_NOWAIT); + toep = malloc(sizeof(struct toepcb), M_DEVBUF, M_NOWAIT|M_ZERO); if (toep == NULL) return (NULL); @@ -152,7 +153,6 @@ void toepcb_init(struct toepcb *toep) { - bzero(toep, sizeof(*toep)); toep->tp_refcount = 1; cv_init(&toep->tp_cv, "toep cv"); } @@ -203,9 +203,6 @@ struct toedev *tdev; struct adap_ports *port_info; - printf("%s called\n", __FUNCTION__); - - t = malloc(sizeof(*t), M_CXGB, M_NOWAIT|M_ZERO); if (t == NULL) @@ -353,6 +350,10 @@ t3_init_tunables(t); mtx_init(&t->listen_lock, "tom data listeners", NULL, MTX_DEF); + + printf("KTR_TOM=0x%x ktr_mask=0x%x KTR_COMPILE=0x%x doing test KTR entry now\n", KTR_TOM, ktr_mask, KTR_COMPILE); + CTR2(KTR_TOM, "t3_toe_attach dev=%p entry=%p", dev, entry); + /* Adjust TOE activation for this module */ t->conf.activated = activated; @@ -379,7 +380,7 @@ t->rx_page_size = rx_page_info.page_size; /* OK if this fails, we just can't do DDP */ t->nppods = (ddp.ulimit + 1 - ddp.llimit) / PPOD_SIZE; - t->ppod_map = malloc(t->nppods, M_DEVBUF, M_WAITOK); + t->ppod_map = malloc(t->nppods, M_DEVBUF, M_WAITOK|M_ZERO); mtx_init(&t->ppod_map_lock, "ppod map", NULL, MTX_DEF); @@ -440,19 +441,7 @@ t3_tom_init(void) { -#if 0 - struct socket *sock; - err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); - if (err < 0) { - printk(KERN_ERR "Could not create TCP socket, error %d\n", err); - return err; - } - t3_def_state_change = sock->sk->sk_state_change; - t3_def_data_ready = sock->sk->sk_data_ready; - t3_def_error_report = sock->sk->sk_error_report; - sock_release(sock); -#endif init_cpl_handlers(); if (t3_init_cpl_io() < 0) return -1; ==== //depot/projects/iwarp/sys/modules/cxgb/tom/Makefile#5 (text+ko) ==== @@ -7,7 +7,7 @@ SRCS= cxgb_tom.c cxgb_cpl_io.c cxgb_listen.c cxgb_tom_sysctl.c cxgb_cpl_socket.c SRCS+= cxgb_ddp.c cxgb_vm.c SRCS+= opt_compat.h opt_inet.h opt_inet6.h opt_ipsec.h opt_mac.h -SRCS+= opt_tcpdebug.h opt_ddb.h opt_sched.h +SRCS+= opt_tcpdebug.h opt_ddb.h opt_sched.h opt_global.h opt_ktr.h SRCS+= device_if.h bus_if.h pci_if.h #CFLAGS+= -DDEBUG_PRINT -DDEBUG