PERFORCE change 128645 for review
Kip Macy
kmacy at FreeBSD.org
Sun Nov 4 14:41:05 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=128645
Change 128645 by kmacy at kmacy:storage:toestack on 2007/11/04 22:40:52
add configuration option of DISABLE_TCP_OFFLOAD so that offload hooks become no-ops
add hooks for offload listen close
add eventhandler hooks for listen offload start and stop
Affected files ...
.. //depot/projects/toestack/sys/netinet/tcp_ofld.c#5 edit
.. //depot/projects/toestack/sys/netinet/tcp_ofld.h#6 edit
.. //depot/projects/toestack/sys/netinet/tcp_subr.c#7 edit
.. //depot/projects/toestack/sys/netinet/tcp_usrreq.c#7 edit
Differences ...
==== //depot/projects/toestack/sys/netinet/tcp_ofld.c#5 (text+ko) ====
@@ -65,43 +65,40 @@
}
int
-ofld_disconnect(struct tcpcb *tp)
+ofld_send(struct tcpcb *tp)
{
-
- return tp->t_tu->tu_disconnect(tp);
+ return tp->t_tu->tu_send(tp);
}
int
-ofld_abort(struct tcpcb *tp)
+ofld_rcvd(struct tcpcb *tp)
{
- return tp->t_tu->tu_abort(tp);
+ return tp->t_tu->tu_rcvd(tp);
}
int
-ofld_send(struct tcpcb *tp)
+ofld_disconnect(struct tcpcb *tp)
{
-
- return tp->t_tu->tu_send(tp);
+ return tp->t_tu->tu_disconnect(tp);
}
int
-ofld_listen(struct tcpcb *tp)
+ofld_abort(struct tcpcb *tp)
{
+ return tp->t_tu->tu_abort(tp);
+}
- return tp->t_tu->tu_listen_start(tp);
+void
+ofld_listen_open(struct tcpcb *tp)
+{
+ EVENTHANDLER_INVOKE(ofld_listen, OFLD_LISTEN_OPEN, tp);
}
-int
+void
ofld_listen_close(struct tcpcb *tp)
{
-
- return tp->t_tu->tu_listen_stop(tp);
+ EVENTHANDLER_INVOKE(ofld_listen, OFLD_LISTEN_CLOSE, tp);
}
-int
-ofld_rcvd(struct tcpcb *tp)
-{
- return tp->t_tu->tu_rcvd(tp);
-}
==== //depot/projects/toestack/sys/netinet/tcp_ofld.h#6 (text+ko) ====
@@ -5,18 +5,18 @@
#define tp_offload(tp) ((tp)->t_flags & TF_TOE)
#define SO_OFFLOADABLE(so) ((so->so_options & SO_NOOFFLOAD) == 0)
-
int ofld_connect(struct socket *so, struct sockaddr *nam);
int ofld_can_offload(struct tcpcb *tp, struct sockaddr *nam);
+
+int ofld_send(struct tcpcb *tp);
+int ofld_rcvd(struct tcpcb *tp);
int ofld_disconnect(struct tcpcb *tp);
int ofld_abort(struct tcpcb *tp);
-int ofld_send(struct tcpcb *tp);
-int ofld_listen(struct tcpcb *tp);
-int ofld_listen_close(struct tcpcb *tp);
-int ofld_rcvd(struct tcpcb *tp);
+void ofld_listen_open(struct tcpcb *tp);
+void ofld_listen_close(struct tcpcb *tp);
-
+#ifndef DISABLE_TCP_OFFLOAD
static __inline int
tcp_gen_connect(struct socket *so, struct sockaddr *nam)
{
@@ -72,36 +72,81 @@
}
static __inline int
-tcp_gen_listen(struct tcpcb *tp)
+tcp_gen_rcvd(struct tcpcb *tp)
{
int error;
if (tp_offload(tp))
- error = ofld_listen(tp);
+ error = ofld_rcvd(tp);
+ else
+ error = tcp_output(tp);
return (error);
}
+static __inline void
+tcp_gen_listen_open(struct tcpcb *tp)
+{
+ if (SO_OFFLOADABLE(tp->t_inpcb->inp_socket))
+ ofld_listen_open(tp);
+}
+
+static __inline void
+tcp_gen_listen_close(struct tcpcb *tp)
+{
+ ofld_listen_close(tp);
+}
+#else
+
static __inline int
+tcp_gen_connect(struct socket *so, struct sockaddr *nam)
+{
+ return tcp_output(tp);
+}
+
+static __inline int
+tcp_gen_disconnect(struct tcpcb *tp)
+{
+ return tcp_output(tp);
+}
+
+static __inline int
+tcp_gen_abort(struct tcpcb *tp)
+{
+ return tcp_output(tp);
+}
+
+static __inline int
+tcp_gen_send(struct tcpcb *tp)
+{
+ return tcp_output(tp);
+}
+
+static __inline int
tcp_gen_rcvd(struct tcpcb *tp)
{
- int error;
+ return tcp_output(tp);
+}
+
+static __inline void
+tcp_gen_listen_open(struct tcpcb *tp) {}
- if (tp_offload(tp))
- error = ofld_rcvd(tp);
- else
- error = tcp_output(tp);
+static __inline void
+tcp_gen_listen_close(struct tcpcb *tp) {}
- return (error);
-}
+#endif
struct toe_usrreqs {
+ int (*tu_send)(struct tcpcb *tp);
+ int (*tu_rcvd)(struct tcpcb *tp);
int (*tu_disconnect)(struct tcpcb *tp);
int (*tu_abort)(struct tcpcb *tp);
- int (*tu_send)(struct tcpcb *tp);
- int (*tu_listen_start)(struct tcpcb *tp);
- int (*tu_listen_stop)(struct tcpcb *tp);
- int (*tu_rcvd)(struct tcpcb *tp);
+
};
+#define OFLD_LISTEN_OPEN 1
+#define OFLD_LISTEN_CLOSE 2
+typedef void (*ofld_listen_fn)(void *, int, struct tcpcb *);
+EVENTHANDLER_DECLARE(ofld_listen, ofld_listen_fn);
+
#endif
==== //depot/projects/toestack/sys/netinet/tcp_subr.c#7 (text+ko) ====
@@ -769,6 +769,9 @@
INP_INFO_WLOCK_ASSERT(&tcbinfo);
INP_LOCK_ASSERT(inp);
+ if (tp->t_state == TCPS_LISTEN)
+ tcp_gen_listen_close(tp);
+
in_pcbdrop(inp);
tcpstat.tcps_closed++;
KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL"));
==== //depot/projects/toestack/sys/netinet/tcp_usrreq.c#7 (text+ko) ====
@@ -386,7 +386,7 @@
if (error == 0) {
tp->t_state = TCPS_LISTEN;
solisten_proto(so, backlog);
- tcp_gen_listen(tp);
+ tcp_gen_listen_open(tp);
}
SOCK_UNLOCK(so);
@@ -1513,8 +1513,9 @@
INP_LOCK_ASSERT(tp->t_inpcb);
switch (tp->t_state) {
+ case TCPS_LISTEN:
+ tcp_gen_listen_close(tp);
case TCPS_CLOSED:
- case TCPS_LISTEN:
tp->t_state = TCPS_CLOSED;
tp = tcp_close(tp);
/*
More information about the p4-projects
mailing list