PERFORCE change 129545 for review
Kip Macy
kmacy at FreeBSD.org
Sun Nov 25 21:33:31 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=129545
Change 129545 by kmacy at kmacy:storage:toestack on 2007/11/26 05:33:29
- set SB_TOE on socket buffers so as not to mess up accounting
- pass toepcb to cxgb_alloc_atid so that all rpl routines expect a
toepcb
Affected files ...
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#26 edit
Differences ...
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#26 (text+ko) ====
@@ -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;
- DPRINTF("tail=%p snd.cc=%d tp_last=%p\n", tail, so->so_snd.sb_cc,
+ printf("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) {
@@ -273,7 +273,8 @@
last = tail = tail->m_next;
}
- if ((toep->tp_wr_avail == 0 ) || (tail == NULL)) {
+ if ((toep->tp_wr_avail == 0 ) || (tail == NULL)) {
+ DPRINTF("wr_avail=%d tail=%p\n", toep->tp_wr_avail, tail);
SOCKBUF_UNLOCK(&so->so_snd);
return (0);
}
@@ -298,6 +299,9 @@
*/
segp->ds_addr = (bus_addr_t)tail->m_data;
segp->ds_len = tail->m_len;
+ DPRINTF("count=%d wr_needed=%d ds_addr=%p ds_len=%d\n",
+ count, mbuf_wrs[count], tail->m_data, tail->m_len);
+
segp++;
tail = tail->m_next;
}
@@ -308,7 +312,9 @@
toep->tp_m_last = NULL;
} else
toep->tp_m_last = so->so_snd.sb_sndptr = last;
-
+
+ DPRINTF("toep->tp_m_last=%p\n", toep->tp_m_last);
+
so->so_snd.sb_sndptroff += bytes;
total_bytes += bytes;
toep->tp_write_seq += bytes;
@@ -812,13 +818,10 @@
static inline void
free_atid(struct t3cdev *cdev, unsigned int tid)
{
- struct socket *so = cxgb_free_atid(cdev, tid);
- if (so) {
- struct tcpcb *tp = sototcpcb(so);
- struct toepcb *toep = tp->t_toe;
+ struct toepcb *toep = cxgb_free_atid(cdev, tid);
+ if (toep)
toepcb_release(toep);
- }
}
/*
@@ -936,21 +939,20 @@
* Assign offload parameters to some socket fields. This code is used by
* both active and passive opens.
*/
-static inline int
+static inline void
init_offload_socket(struct socket *so, struct toedev *dev, unsigned int tid,
- struct l2t_entry *e, struct rtentry *dst)
+ struct l2t_entry *e, struct rtentry *dst, struct toepcb *toep)
{
struct tcpcb *tp = sototcpcb(so);
- struct toepcb *toep;
struct t3c_data *td = T3C_DATA(TOM_DATA(dev)->cdev);
- toep = toepcb_alloc();
- if (toep == NULL)
- return (ENOMEM);
printf("initializing offload socket\n");
+ so->so_rcv.sb_flags |= SB_TOE;
+ so->so_snd.sb_flags |= SB_TOE;
+
tp->t_toe = toep;
-
+ toep->tp_tp = tp;
toep->tp_toedev = dev;
toep->tp_tid = tid;
@@ -968,7 +970,6 @@
reset_wr_list(tp);
DPRINTF("initialization done\n");
- return (0);
}
/*
@@ -1120,7 +1121,9 @@
do_act_open_rpl(struct t3cdev *cdev, struct mbuf *m, void *ctx)
{
struct toepcb *toep = (struct toepcb *)ctx;
- struct socket *so = toeptoso(toep);
+ struct socket *so;
+
+ so = toeptoso(toep);
#ifdef notyet
struct cpl_act_open_rpl *rpl = cplhdr(m);
@@ -1178,9 +1181,13 @@
struct rtentry *dst = inp->inp_route.ro_rt;
struct toepcb *toep; /* allocated by init_offload_socket */
- int atid, err;
+ int atid;
- if ((atid = cxgb_alloc_atid(d->cdev, d->client, so)) < 0)
+ toep = toepcb_alloc();
+ if (toep == NULL)
+ goto out_err;
+
+ if ((atid = cxgb_alloc_atid(d->cdev, d->client, toep)) < 0)
goto out_err;
e = t3_l2t_get(d->cdev, dst, egress_ifp);
@@ -1188,21 +1195,23 @@
goto free_tid;
m = m_gethdr(MT_DATA, M_WAITOK);
- m_set_toep(m, tp->t_toe);
#if 0
m->m_toe.mt_toepcb = tp->t_toe;
set_arp_failure_handler((struct mbuf *)m, act_open_req_arp_failure);
#endif
- if ((err = init_offload_socket(so, tdev, atid, e, dst)))
- return (err);
-
+ init_offload_socket(so, tdev, atid, e, dst, toep);
+
install_offload_ops(so);
+
mk_act_open_req(so, m, atid, e);
soisconnecting(so);
+ toep = tp->t_toe;
+ m_set_toep(m, tp->t_toe);
+
+ DPRINTF("toep=%p toep->tp_tp=%p\n", toep, toep->tp_tp);
+
l2t_send(d->cdev, (struct mbuf *)m, e);
-
- toep = tp->t_toe;
if (toep->tp_ulp_mode)
t3_enable_ddp(so, 0);
return (0);
@@ -1432,6 +1441,19 @@
SOCKBUF_LOCK(&so->so_rcv);
if (sb_notify(&so->so_rcv))
printf("rx_data so=%p flags=0x%x len=%d\n", so, so->so_rcv.sb_flags, m->m_pkthdr.len);
+ if (m->m_pkthdr.len == 80) {
+ int i;
+ uint64_t *data;
+
+ data = mtod(m, uint64_t *);
+ printf("80 byte packet:\n");
+ for (i = 0; i < 10; i++, data++) {
+ uint8_t *dp = (uint8_t *)data;
+
+ printf("%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ dp[0],dp[1],dp[2],dp[3],dp[4],dp[5],dp[6],dp[7]);
+ }
+ }
sbappendstream_locked(&so->so_rcv, m);
@@ -2862,6 +2884,8 @@
}
tp = sototcpcb(so);
+ so->so_snd.sb_flags |= SB_TOE;
+ so->so_rcv.sb_flags |= SB_TOE;
toep->tp_tp = tp;
tp->t_toe = toep;
reset_wr_list(tp);
@@ -3017,11 +3041,11 @@
struct cpl_act_establish *req = cplhdr(m);
unsigned int tid = GET_TID(req);
unsigned int atid = G_PASS_OPEN_TID(ntohl(req->tos_tid));
- struct socket *so = (struct socket *)ctx;
- struct toedev *tdev = TOE_DEV(so);
+ struct toepcb *toep = (struct toepcb *)ctx;
+ struct tcpcb *tp = toep->tp_tp;
+ struct socket *so = toeptoso(toep);
+ struct toedev *tdev = TOE_DEV(so); /* blow up here if link was down */
struct tom_data *d = TOM_DATA(tdev);
- struct tcpcb *tp = sototcpcb(so);
- struct toepcb *toep = tp->t_toe;
INP_LOCK(tp->t_inpcb);
@@ -3134,7 +3158,7 @@
if (so->so_snd.sb_sndptroff < so->so_snd.sb_cc)
t3_push_frames(so, 0);
-
+
out_free:
INP_UNLOCK(tp->t_inpcb);
m_free(m);
More information about the p4-projects
mailing list