PERFORCE change 129440 for review
Kip Macy
kmacy at FreeBSD.org
Fri Nov 23 19:17:27 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=129440
Change 129440 by kmacy at kmacy:storage:toestack on 2007/11/24 03:16:48
convert printfs in the I/O path to DPRINTF
fix locking in close to not dereference destroyed tcpcb
Affected files ...
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#24 edit
Differences ...
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#24 (text+ko) ====
@@ -149,11 +149,11 @@
static void
dump_toepcb(struct toepcb *toep)
{
- printf("qset_idx=%d qset=%d ulp_mode=%d mtu_idx=%d tid=%d\n",
+ DPRINTF("qset_idx=%d qset=%d ulp_mode=%d mtu_idx=%d tid=%d\n",
toep->tp_qset_idx, toep->tp_qset, toep->tp_ulp_mode,
toep->tp_mtu_idx, toep->tp_tid);
- printf("wr_max=%d wr_avail=%d wr_unacked=%d mss_clamp=%d flags=0x%x\n",
+ DPRINTF("wr_max=%d wr_avail=%d wr_unacked=%d mss_clamp=%d flags=0x%x\n",
toep->tp_wr_max, toep->tp_wr_avail, toep->tp_wr_unacked,
toep->tp_mss_clamp, toep->tp_flags);
}
@@ -249,12 +249,12 @@
segp = segs;
if (tp->t_state == TCPS_SYN_SENT || tp->t_state == TCPS_CLOSED) {
- printf("tcp state=%d\n", tp->t_state);
+ DPRINTF("tcp state=%d\n", tp->t_state);
return (0);
}
if (so->so_state & (SS_ISDISCONNECTING|SS_ISDISCONNECTED)) {
- printf("disconnecting\n");
+ DPRINTF("disconnecting\n");
return (0);
}
@@ -265,7 +265,7 @@
cdev = d->cdev;
last = tail = so->so_snd.sb_sndptr ? so->so_snd.sb_sndptr : so->so_snd.sb_mb;
total_bytes = 0;
- printf("tail=%p snd.cc=%d tp_last=%p\n", tail, so->so_snd.sb_cc,
+ DPRINTF("tail=%p snd.cc=%d tp_last=%p\n", tail, so->so_snd.sb_cc,
toep->tp_m_last);
if (last && toep->tp_m_last == last) {
@@ -301,7 +301,7 @@
segp++;
tail = tail->m_next;
}
- printf("wr_avail=%d mbuf_wrs[%d]=%d tail=%p\n",
+ DPRINTF("wr_avail=%d mbuf_wrs[%d]=%d tail=%p\n",
toep->tp_wr_avail, count, mbuf_wrs[count], tail);
if (tail) {
so->so_snd.sb_sndptr = tail;
@@ -342,7 +342,7 @@
m0->m_type = MT_DONTFREE;
enqueue_wr(tp, m0);
- printf("sending offload tx with %d bytes in %d segments\n",
+ DPRINTF("sending offload tx with %d bytes in %d segments\n",
bytes, count);
l2t_send(cdev, m0, toep->tp_l2t);
@@ -426,7 +426,7 @@
m = m_gethdr_nofail(sizeof(*req));
- printf("returning %u credits to HW\n", credits);
+ DPRINTF("returning %u credits to HW\n", credits);
req = mtod(m, struct cpl_rx_data_ack *);
req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
@@ -465,7 +465,7 @@
toep->tp_copied_seq += read;
toep->tp_enqueued_bytes -= read;
credits = toep->tp_copied_seq - toep->tp_rcv_wup;
- printf("copied_seq=%u rcv_wup=%u credits=%u\n",
+ DPRINTF("copied_seq=%u rcv_wup=%u credits=%u\n",
toep->tp_copied_seq, toep->tp_rcv_wup, credits);
/*
@@ -533,7 +533,7 @@
{
struct socket *so;
- printf("cxgb_toe_send\n");
+ DPRINTF("cxgb_toe_send\n");
dump_toepcb(tp->t_toe);
so = tp->t_inpcb->inp_socket;
@@ -869,6 +869,8 @@
{
struct tcpcb *tp = sototcpcb(so);
+ KASSERT(tp->t_toe != NULL, ("toepcb not set"));
+
t3_install_socket_ops(so);
tp->t_flags |= TF_TOE;
tp->t_tu = &cxgb_toe_usrreqs;
@@ -962,7 +964,7 @@
toep->tp_qset_idx = 0;
reset_wr_list(tp);
- printf("initialization done\n");
+ DPRINTF("initialization done\n");
return (0);
}
@@ -989,7 +991,7 @@
val = V_TOS(SO_TOS(so)) | V_ULP_MODE(ulp_mode) |
V_RCV_BUFSIZ(min(tp->rcv_wnd >> 10, (u32)M_RCV_BUFSIZ));
- printf("opt0l tos=%08x rcv_wnd=%ld opt0l=%08x\n", SO_TOS(so), tp->rcv_wnd, val);
+ DPRINTF("opt0l tos=%08x rcv_wnd=%ld opt0l=%08x\n", SO_TOS(so), tp->rcv_wnd, val);
return (val);
}
@@ -1028,7 +1030,7 @@
req->peer_port = inp->inp_fport;
memcpy(&req->local_ip, &inp->inp_laddr, 4);
memcpy(&req->peer_ip, &inp->inp_faddr, 4);
- printf("connect smt_idx=%d\n", e->smt_idx);
+ DPRINTF("connect smt_idx=%d\n", e->smt_idx);
req->opt0h = htonl(calc_opt0h(so, toep->tp_mtu_idx) | V_L2T_IDX(e->idx) |
V_TX_CHANNEL(e->smt_idx));
req->opt0l = htonl(calc_opt0l(so, toep->tp_ulp_mode));
@@ -1409,7 +1411,7 @@
toep->tp_delack_seq = tp->rcv_nxt;
}
- printf("appending mbuf=%p pktlen=%d m_len=%d len=%d\n", m, m->m_pkthdr.len, m->m_len, len);
+ DPRINTF("appending mbuf=%p pktlen=%d m_len=%d len=%d\n", m, m->m_pkthdr.len, m->m_len, len);
if (len < m->m_pkthdr.len)
m->m_pkthdr.len = m->m_len = len;
@@ -1437,7 +1439,7 @@
{
struct toepcb *toep = (struct toepcb *)ctx;
- printf("rx_data len=%d\n", m->m_pkthdr.len);
+ DPRINTF("rx_data len=%d\n", m->m_pkthdr.len);
new_rx_data(toep, m);
@@ -1770,6 +1772,7 @@
process_close_con_rpl(struct socket *so, struct mbuf *m)
{
struct tcpcb *tp = sototcpcb(so);
+ struct inpcb *inp = tp->t_inpcb;
struct cpl_close_con_rpl *rpl = cplhdr(m);
struct toepcb *toep = tp->t_toe;
@@ -1783,10 +1786,10 @@
t3_release_offload_resources(so);
if (toep->tp_flags & TP_ABORT_RPL_PENDING) {
INP_INFO_WLOCK(&tcbinfo);
- INP_LOCK(tp->t_inpcb);
+ INP_LOCK(inp);
tcp_close(tp);
INP_INFO_WUNLOCK(&tcbinfo);
- INP_UNLOCK(tp->t_inpcb);
+ INP_UNLOCK(inp);
} else
enter_timewait(so);
break;
@@ -1798,10 +1801,10 @@
*/
t3_release_offload_resources(so);
INP_INFO_WLOCK(&tcbinfo);
- INP_LOCK(tp->t_inpcb);
+ INP_LOCK(inp);
tcp_close(tp);
INP_INFO_WUNLOCK(&tcbinfo);
- INP_UNLOCK(tp->t_inpcb);
+ INP_UNLOCK(inp);
break;
case TCPS_FIN_WAIT_1:
@@ -2427,7 +2430,7 @@
inc.inc_ext = toep;
inc.inc_eh = handle_syncache_event;
- printf("syncache add of %d:%d %d:%d\n",
+ DPRINTF("syncache add of %d:%d %d:%d\n",
ntohl(req->local_ip), ntohs(req->local_port),
ntohl(req->peer_ip), ntohs(req->peer_port));
@@ -2477,13 +2480,13 @@
cxgb_queue_tid_release(cdev, tid);
m_free(m);
}
- printf("failed to get reply_mbuf\n");
+ DPRINTF("failed to get reply_mbuf\n");
goto out;
}
if (tp->t_state != TCPS_LISTEN) {
- printf("socket not in listen state\n");
+ DPRINTF("socket not in listen state\n");
goto reject;
}
@@ -2491,7 +2494,7 @@
tim.mac_addr = req->dst_mac;
tim.vlan_tag = ntohs(req->vlan_tag);
if (cdev->ctl(cdev, GET_IFF_FROM_MAC, &tim) < 0 || !tim.dev) {
- printf("rejecting from failed GET_IFF_FROM_MAC\n");
+ DPRINTF("rejecting from failed GET_IFF_FROM_MAC\n");
goto reject;
}
@@ -2535,13 +2538,13 @@
if (dst == NULL) {
- printf("failed to find route\n");
+ DPRINTF("failed to find route\n");
}
e = newtoep->tp_l2t = t3_l2t_get(d->cdev, dst, tim.dev);
if (e == NULL) {
- printf("failed to get l2t\n");
+ DPRINTF("failed to get l2t\n");
}
/*
@@ -2552,7 +2555,7 @@
newtoep->tp_tid = tid;
newtoep->tp_toedev = tdev;
- printf("inserting tid=%d\n", tid);
+ DPRINTF("inserting tid=%d\n", tid);
cxgb_insert_tid(cdev, d->client, newtoep, tid);
if (lctx->ulp_mode) {
@@ -2566,7 +2569,7 @@
set_arp_failure_handler(reply_mbuf, pass_accept_rpl_arp_failure);
- printf("adding request to syn cache\n");
+ DPRINTF("adding request to syn cache\n");
syncache_add_accept_req(req, so, newtoep);
@@ -2579,27 +2582,28 @@
rpl->rsvd = rpl->opt2; /* workaround for HW bug */
rpl->peer_ip = req->peer_ip; // req->peer_ip is not overwritten
- printf("accept smt_idx=%d\n", e->smt_idx);
+ DPRINTF("accept smt_idx=%d\n", e->smt_idx);
rpl->opt0h = htonl(calc_opt0h(so, select_mss(td, NULL, dst->rt_ifp->if_mtu)) |
V_L2T_IDX(e->idx) | V_TX_CHANNEL(e->smt_idx));
rpl->opt0l_status = htonl(calc_opt0l(so, lctx->ulp_mode) |
CPL_PASS_OPEN_ACCEPT);
- printf("opt0l_status=%08x\n", rpl->opt0l_status);
+ DPRINTF("opt0l_status=%08x\n", rpl->opt0l_status);
m_set_priority(reply_mbuf, mkprio(CPL_PRIORITY_SETUP, so));
+#ifdef DEBUG_PRINT
{
int i;
- printf("rpl:\n");
+ DPRINTF("rpl:\n");
uint32_t *rplbuf = mtod(reply_mbuf, uint32_t *);
for (i = 0; i < sizeof(*rpl)/sizeof(uint32_t); i++)
- printf("[%d] %08x\n", i, rplbuf[i]);
+ DPRINTF("[%d] %08x\n", i, rplbuf[i]);
}
-
+#endif
l2t_send(cdev, reply_mbuf, e);
@@ -3015,7 +3019,7 @@
u32 snd_una = ntohl(hdr->snd_una);
int bytes = 0;
- printf("wr_ack: snd_una=%u credits=%d\n", snd_una, credits);
+ DPRINTF("wr_ack: snd_una=%u credits=%d\n", snd_una, credits);
toep->tp_wr_avail += credits;
if (toep->tp_wr_unacked > toep->tp_wr_max - toep->tp_wr_avail)
@@ -3023,7 +3027,7 @@
while (credits) {
struct mbuf *p = peek_wr(tp);
- printf("p->credits=%d p->bytes=%d\n", p->m_pkthdr.csum_data, p->m_pkthdr.len) ;
+ DPRINTF("p->credits=%d p->bytes=%d\n", p->m_pkthdr.csum_data, p->m_pkthdr.len) ;
if (__predict_false(!p)) {
log(LOG_ERR, "%u WR_ACK credits for TID %u with "
@@ -3051,7 +3055,7 @@
dequeue_wr(tp);
credits -= p->m_pkthdr.csum_data;
bytes += p->m_pkthdr.len;
- printf("done with wr of %d bytes\n", p->m_pkthdr.len);
+ DPRINTF("done with wr of %d bytes\n", p->m_pkthdr.len);
m_free(p);
}
@@ -3085,7 +3089,7 @@
toep->tp_flags &= ~TP_TX_WAIT_IDLE;
}
if (bytes) {
- printf("sbdrop(%d)\n", bytes);
+ DPRINTF("sbdrop(%d)\n", bytes);
sbdrop(&so->so_snd, bytes);
}
@@ -3105,7 +3109,7 @@
{
struct toepcb *toep = (struct toepcb *)ctx;
- printf("do_wr_ack\n");
+ DPRINTF("do_wr_ack\n");
dump_toepcb(toep);
VALIDATE_SOCK(so);
More information about the p4-projects
mailing list