PERFORCE change 130940 for review
Kip Macy
kmacy at FreeBSD.org
Fri Dec 14 20:29:46 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=130940
Change 130940 by kmacy at kmacy:storage:toestack on 2007/12/15 04:29:02
add synq to listen_ctx
add support for sending reset in SYN_RCVD state
style fixes to inline functions
Affected files ...
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#34 edit
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_defs.h#13 edit
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_listen.c#7 edit
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h#4 edit
.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_tom.h#16 edit
Differences ...
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#34 (text+ko) ====
@@ -140,7 +140,7 @@
extern int tcp_autorcvbuf_max;
extern int tcp_autosndbuf_max;
-static void t3_send_reset(struct socket *so);
+static void t3_send_reset(struct toepcb *toep);
static void send_abort_rpl(struct mbuf *m, struct toedev *tdev, int rst_status);
static inline void free_atid(struct t3cdev *cdev, unsigned int tid);
static void handle_syncache_event(int event, void *arg);
@@ -550,17 +550,15 @@
static int
cxgb_toe_abort(struct tcpcb *tp)
{
- struct socket *so;
- struct toepcb *toep;
+ struct toepcb *toep = tp->t_toe;
+
- so = tp->t_inpcb->inp_socket;
- t3_send_reset(so);
+ t3_send_reset(toep);
/*
* unhook from socket
*/
tp->t_flags &= ~TF_TOE;
- toep = tp->t_toe;
toep->tp_tp = NULL;
tp->t_toe = NULL;
return (0);
@@ -1301,24 +1299,31 @@
* an ABORT_REQ wasn't generated after all, 0 otherwise.
*/
static void
-t3_send_reset(struct socket *so)
+t3_send_reset(struct toepcb *toep)
{
struct cpl_abort_req *req;
- struct tcpcb *tp = sototcpcb(so);
- struct toepcb *toep = tp->t_toe;
unsigned int tid = toep->tp_tid;
int mode = CPL_ABORT_SEND_RST;
+ struct tcpcb *tp = toep->tp_tp;
+ struct toedev *tdev = toep->tp_toedev;
+ struct socket *so = NULL;
struct mbuf *m;
- INP_LOCK_ASSERT(tp->t_inpcb);
- if (__predict_false((toep->tp_flags & TP_ABORT_SHUTDOWN) || !TOE_DEV(so)))
+ if (tp) {
+ INP_LOCK_ASSERT(tp->t_inpcb);
+ so = toeptoso(toep);
+ }
+
+ if (__predict_false((toep->tp_flags & TP_ABORT_SHUTDOWN) ||
+ tdev == NULL))
return;
toep->tp_flags |= (TP_ABORT_RPL_PENDING|TP_ABORT_SHUTDOWN);
/* Purge the send queue so we don't send anything after an abort. */
- sbflush(&so->so_snd);
- if ((toep->tp_flags & TP_CLOSE_CON_REQUESTED) && is_t3a(TOE_DEV(so)))
+ if (so)
+ sbflush(&so->so_snd);
+ if ((toep->tp_flags & TP_CLOSE_CON_REQUESTED) && is_t3a(tdev))
mode |= CPL_ABORT_POST_CLOSE_REQ;
m = m_gethdr_nofail(sizeof(*req));
@@ -1329,14 +1334,13 @@
req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_REQ));
req->wr.wr_lo = htonl(V_WR_TID(tid));
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ABORT_REQ, tid));
- req->rsvd0 = htonl(tp->snd_nxt);
+ req->rsvd0 = tp ? htonl(tp->snd_nxt) : 0;
req->rsvd1 = !(toep->tp_flags & TP_DATASENT);
req->cmd = mode;
- INP_LOCK_ASSERT(tp->t_inpcb);
- if (tp->t_state == TCPS_SYN_SENT)
+ if (tp && (tp->t_state == TCPS_SYN_SENT))
mbufq_tail(&toep->out_of_order_queue, m); // defer
else
- l2t_send(T3C_DEV(so), m, toep->tp_l2t);
+ l2t_send(TOEP_T3C_DEV(toep), m, toep->tp_l2t);
}
static int
@@ -2633,7 +2637,11 @@
printf("inserting tid=%d\n", tid);
cxgb_insert_tid(cdev, d->client, newtoep, tid);
-
+ SOCK_LOCK(so);
+ LIST_INSERT_HEAD(&lctx->synq_head, newtoep, synq_entry);
+ SOCK_UNLOCK(so);
+
+
if (lctx->ulp_mode) {
ddp_mbuf = m_gethdr(M_NOWAIT, MT_DATA);
@@ -2653,6 +2661,8 @@
toepcb_hold(newtoep);
syncache_add_accept_req(req, so, newtoep);
+
+
rpl = cplhdr(reply_mbuf);
reply_mbuf->m_pkthdr.len = reply_mbuf->m_len = sizeof(*rpl);
rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
@@ -2892,8 +2902,11 @@
so = lso = toeptoso(toep);
tdev = toep->tp_toedev;
+
+ SOCK_LOCK(so);
+ LIST_REMOVE(toep, synq_entry);
+ SOCK_UNLOCK(so);
-
INP_INFO_WLOCK(&tcbinfo);
if (!syncache_expand_establish_req(req, &so, toep)) {
/*
@@ -3235,7 +3248,9 @@
static void
t3_reset_listen_child(struct socket *child)
{
- t3_send_reset(child);
+ struct tcpcb *tp = sototcpcb(child);
+
+ t3_send_reset(tp->t_toe);
}
/*
@@ -3267,17 +3282,20 @@
*/
void
-t3_reset_synq(struct socket *listen_so)
+t3_reset_synq(struct listen_ctx *lctx)
{
- struct socket *so;
- struct tcpcb *tp;
+ struct toepcb *toep;
- TAILQ_FOREACH(so, &listen_so->so_incomp, so_list) {
- tp = sototcpcb(so);
-
- if (tp->t_flags & TF_TOE)
- t3_reset_listen_child(so);
+ SOCK_LOCK(lctx->lso);
+ while (!LIST_EMPTY(&lctx->synq_head)) {
+ toep = LIST_FIRST(&lctx->synq_head);
+ LIST_REMOVE(toep, synq_entry);
+ toep->tp_tp = NULL;
+ t3_send_reset(toep);
+ cxgb_remove_tid(TOEP_T3C_DEV(toep), toep, toep->tp_tid);
+ toepcb_release(toep);
}
+ SOCK_UNLOCK(lctx->lso);
}
void
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_defs.h#13 (text+ko) ====
@@ -40,6 +40,8 @@
#define toeptoso(toep) ((toep)->tp_tp->t_inpcb->inp_socket)
#define sototoep(so) (sototcpcb((so))->t_toe)
+struct listen_ctx;
+
typedef void (*defer_handler_t)(struct toedev *dev, struct mbuf *m);
void t3tom_register_cpl_handler(unsigned int opcode, cxgb_cpl_handler_func h);
@@ -59,7 +61,7 @@
void t3_disconnect_acceptq(struct socket *listen_so);
-void t3_reset_synq(struct socket *listen_so);
+void t3_reset_synq(struct listen_ctx *ctx);
void t3_defer_reply(struct mbuf *m, struct toedev *dev, defer_handler_t handler);
struct toepcb *toepcb_alloc(void);
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_listen.c#7 (text+ko) ====
@@ -70,7 +70,10 @@
#include <dev/cxgb/ulp/toecore/cxgb_toedev.h>
#include <dev/cxgb/ulp/tom/cxgb_defs.h>
#include <dev/cxgb/ulp/tom/cxgb_tom.h>
+#include <dev/cxgb/ulp/tom/cxgb_t3_ddp.h>
+#include <dev/cxgb/ulp/tom/cxgb_toepcb.h>
+
static struct listen_info *listen_hash_add(struct tom_data *d, struct socket *so, unsigned int stid);
static int listen_hash_del(struct tom_data *d, struct socket *so);
@@ -91,10 +94,7 @@
struct listen_ctx *listen_ctx = (struct listen_ctx *)ctx;
cxgb_free_stid(cdev, stid);
-#if 0
- sock_put(listen_ctx->lsk);
-#endif
- free(listen_ctx, M_DEVBUF);
+ free(listen_ctx, M_CXGB);
}
return (CPL_RET_BUF_DONE);
@@ -139,7 +139,7 @@
*/
sock_put(lso);
#endif
- free(listen_ctx, M_DEVBUF);
+ free(listen_ctx, M_CXGB);
}
return CPL_RET_BUF_DONE;
}
@@ -166,7 +166,7 @@
{
struct listen_info *p;
- p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO);
+ p = malloc(sizeof(*p), M_CXGB, M_NOWAIT|M_ZERO);
if (p) {
int bucket = listen_hashfn(so);
@@ -220,7 +220,7 @@
if (p->so == so) {
stid = p->stid;
*prev = p->next;
- free(p, M_DEVBUF);
+ free(p, M_CXGB);
break;
}
mtx_unlock(&d->listen_lock);
@@ -246,14 +246,15 @@
printf("start listen\n");
- ctx = malloc(sizeof(*ctx), M_DEVBUF, M_NOWAIT);
-
+ ctx = malloc(sizeof(*ctx), M_CXGB, M_NOWAIT);
+
if (!ctx)
return;
ctx->tom_data = d;
ctx->lso = so;
ctx->ulp_mode = 0; /* DDP if the default */
+ LIST_INIT(&ctx->synq_head);
stid = cxgb_alloc_stid(d->cdev, d->client, ctx);
if (stid < 0)
@@ -297,7 +298,7 @@
sock_put(sk);
#endif
free_ctx:
- free(ctx, M_DEVBUF);
+ free(ctx, M_CXGB);
}
/*
@@ -309,18 +310,20 @@
{
struct mbuf *m;
struct cpl_close_listserv_req *req;
+ struct listen_ctx *lctx;
int stid = listen_hash_del(TOM_DATA(dev), so);
if (stid < 0)
return;
+ lctx = cxgb_get_lctx(cdev, stid);
/*
* Do this early so embryonic connections are marked as being aborted
* while the stid is still open. This ensures pass_establish messages
* that arrive while we are closing the server will be able to locate
* the listening socket.
*/
- t3_reset_synq(so);
+ t3_reset_synq(lctx);
/* Send the close ASAP to stop further passive opens */
m = m_gethdr(M_NOWAIT, MT_DATA);
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h#4 (text+ko) ====
@@ -35,18 +35,22 @@
struct mbuf *tp_m_last;
bus_dma_tag_t tp_tx_dmat;
bus_dmamap_t tp_dmamap;
-
+
+ LIST_ENTRY(toepcb) synq_entry;
struct mbuf_head wr_list;
struct mbuf_head out_of_order_queue;
struct ddp_state tp_ddp_state;
};
-static inline void reset_wr_list(struct toepcb *toep)
+static inline void
+reset_wr_list(struct toepcb *toep)
{
+
mbufq_init(&toep->wr_list);
}
-static inline void purge_wr_queue(struct toepcb *toep)
+static inline void
+purge_wr_queue(struct toepcb *toep)
{
struct mbuf *m;
@@ -54,20 +58,25 @@
m_freem(m);
}
-static inline void enqueue_wr(struct toepcb *toep, struct mbuf *m)
+static inline void
+enqueue_wr(struct toepcb *toep, struct mbuf *m)
{
+
mbufq_tail(&toep->wr_list, m);
}
+static inline struct mbuf *
+peek_wr(struct toepcb *toep)
+{
-static inline struct mbuf *peek_wr(struct toepcb *toep)
-{
- return mbufq_peek(&toep->wr_list);
+ return (mbufq_peek(&toep->wr_list));
}
-static inline struct mbuf *dequeue_wr(struct toepcb *toep)
+static inline struct mbuf *
+dequeue_wr(struct toepcb *toep)
{
- return mbufq_dequeue(&toep->wr_list);
+
+ return (mbufq_dequeue(&toep->wr_list));
}
#endif
==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_tom.h#16 (text+ko) ====
@@ -108,8 +108,6 @@
struct mtx ppod_map_lock;
struct adap_ports *ports;
-
-
struct taskqueue *tq;
};
@@ -118,6 +116,8 @@
struct socket *lso;
struct tom_data *tom_data;
int ulp_mode;
+ LIST_HEAD(, toepcb) synq_head;
+
};
#define TOM_DATA(dev) (*(struct tom_data **)&(dev)->tod_l4opt)
More information about the p4-projects
mailing list