summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2007-12-18 22:59:07 +0000
committerkmacy <kmacy@FreeBSD.org>2007-12-18 22:59:07 +0000
commit7a03620a3b8d5378521bc95997c1b60485cbeaac (patch)
tree39dc8c7b7fba1fe70eea9b304504e23c0a65135a
parentee337f2c349391c3e318ede0c5cff21592e02677 (diff)
downloadFreeBSD-src-7a03620a3b8d5378521bc95997c1b60485cbeaac.zip
FreeBSD-src-7a03620a3b8d5378521bc95997c1b60485cbeaac.tar.gz
Incorporate TCP offload hooks in to core TCP code.
- Rename output routines tcp_gen_* -> tcp_output_*. - Rename notification routines that turn in to no-ops in the absence of TOE from tcp_gen_* -> tcp_offload_*. - Fix some minor comment nits. - Add a /* FALLTHROUGH */ Reviewed by: Sam Leffler, Robert Watson, and Mike Silbersack
-rw-r--r--sys/netinet/tcp_offload.h22
-rw-r--r--sys/netinet/tcp_subr.c11
-rw-r--r--sys/netinet/tcp_usrreq.c22
3 files changed, 34 insertions, 21 deletions
diff --git a/sys/netinet/tcp_offload.h b/sys/netinet/tcp_offload.h
index 33d73ee..21ecba4 100644
--- a/sys/netinet/tcp_offload.h
+++ b/sys/netinet/tcp_offload.h
@@ -216,8 +216,10 @@ EVENTHANDLER_DECLARE(tcp_offload_listen_stop, tcp_offload_listen_stop_fn);
int tcp_offload_connect(struct socket *so, struct sockaddr *nam);
/*
- * The tcp_gen_* routines are wrappers around the toe_usrreqs calls,
- * in the non-offloaded case they translate to tcp_output.
+ * The tcp_output_* routines are wrappers around the toe_usrreqs calls
+ * which trigger packet transmission. In the non-offloaded case they
+ * translate to tcp_output. The tcp_offload_* routines notify TOE
+ * of specific events. I the non-offloaded case they are no-ops.
*
* Listen is a special case because it is a 1 to many relationship
* and there can be more than one offload driver in the system.
@@ -233,7 +235,7 @@ int tcp_offload_connect(struct socket *so, struct sockaddr *nam);
#define SO_OFFLOADABLE(so) ((so->so_options & SO_NO_OFFLOAD) == 0)
static __inline int
-tcp_gen_connect(struct socket *so, struct sockaddr *nam)
+tcp_output_connect(struct socket *so, struct sockaddr *nam)
{
struct tcpcb *tp = sototcpcb(so);
int error;
@@ -251,7 +253,7 @@ tcp_gen_connect(struct socket *so, struct sockaddr *nam)
}
static __inline int
-tcp_gen_send(struct tcpcb *tp)
+tcp_output_send(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
@@ -262,7 +264,7 @@ tcp_gen_send(struct tcpcb *tp)
}
static __inline int
-tcp_gen_rcvd(struct tcpcb *tp)
+tcp_output_rcvd(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
@@ -273,7 +275,7 @@ tcp_gen_rcvd(struct tcpcb *tp)
}
static __inline int
-tcp_gen_disconnect(struct tcpcb *tp)
+tcp_output_disconnect(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
@@ -284,7 +286,7 @@ tcp_gen_disconnect(struct tcpcb *tp)
}
static __inline int
-tcp_gen_reset(struct tcpcb *tp)
+tcp_output_reset(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
@@ -295,7 +297,7 @@ tcp_gen_reset(struct tcpcb *tp)
}
static __inline void
-tcp_gen_detach(struct tcpcb *tp)
+tcp_offload_detach(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
@@ -305,7 +307,7 @@ tcp_gen_detach(struct tcpcb *tp)
}
static __inline void
-tcp_gen_listen_open(struct tcpcb *tp)
+tcp_offload_listen_open(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
@@ -315,7 +317,7 @@ tcp_gen_listen_open(struct tcpcb *tp)
}
static __inline void
-tcp_gen_listen_close(struct tcpcb *tp)
+tcp_offload_listen_close(struct tcpcb *tp)
{
#ifndef TCP_OFFLOAD_DISABLE
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 7d2a677..214dc3e 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_syncache.h>
+#include <netinet/tcp_offload.h>
#ifdef INET6
#include <netinet6/tcp6_var.h>
#endif
@@ -651,7 +652,7 @@ tcp_drop(struct tcpcb *tp, int errno)
if (TCPS_HAVERCVDSYN(tp->t_state)) {
tp->t_state = TCPS_CLOSED;
- (void) tcp_output(tp);
+ (void) tcp_output_reset(tp);
tcpstat.tcps_drops++;
} else
tcpstat.tcps_conndrops++;
@@ -749,6 +750,9 @@ tcp_discardcb(struct tcpcb *tp)
tp->t_segqlen--;
tcp_reass_qsize--;
}
+ /* Disconnect offload device, if any. */
+ tcp_offload_detach(tp);
+
tcp_free_sackholes(tp);
inp->inp_ppcb = NULL;
tp->t_inpcb = NULL;
@@ -768,6 +772,9 @@ tcp_close(struct tcpcb *tp)
INP_INFO_WLOCK_ASSERT(&tcbinfo);
INP_LOCK_ASSERT(inp);
+ /* Notify any offload devices of listener close */
+ if (tp->t_state == TCPS_LISTEN)
+ tcp_offload_listen_close(tp);
in_pcbdrop(inp);
tcpstat.tcps_closed++;
KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL"));
@@ -1562,7 +1569,7 @@ tcp_mtudisc(struct inpcb *inp, int errno)
tp->snd_recover = tp->snd_max;
if (tp->t_flags & TF_SACK_PERMIT)
EXIT_FASTRECOVERY(tp);
- tcp_output(tp);
+ tcp_output_send(tp);
return (inp);
}
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 77413cb..02ab9d0 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
#ifdef TCPDEBUG
#include <netinet/tcp_debug.h>
#endif
+#include <netinet/tcp_offload.h>
/*
* TCP protocol interface to socket abstraction.
@@ -385,6 +386,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td)
if (error == 0) {
tp->t_state = TCPS_LISTEN;
solisten_proto(so, backlog);
+ tcp_offload_listen_open(tp);
}
SOCK_UNLOCK(so);
@@ -476,7 +478,7 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
TCPDEBUG1();
if ((error = tcp_connect(tp, nam, td)) != 0)
goto out;
- error = tcp_output(tp);
+ error = tcp_output_connect(so, nam);
out:
TCPDEBUG2(PRU_CONNECT);
INP_UNLOCK(inp);
@@ -528,7 +530,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
inp->inp_vflag &= ~INP_IPV6;
if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0)
goto out;
- error = tcp_output(tp);
+ error = tcp_output_connect(so, nam);
goto out;
}
inp->inp_vflag &= ~INP_IPV4;
@@ -536,7 +538,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
inp->inp_inc.inc_isipv6 = 1;
if ((error = tcp6_connect(tp, nam, td)) != 0)
goto out;
- error = tcp_output(tp);
+ error = tcp_output_connect(so, nam);
out:
TCPDEBUG2(PRU_CONNECT);
@@ -703,7 +705,7 @@ tcp_usr_shutdown(struct socket *so)
TCPDEBUG1();
socantsendmore(so);
tcp_usrclosed(tp);
- error = tcp_output(tp);
+ error = tcp_output_disconnect(tp);
out:
TCPDEBUG2(PRU_SHUTDOWN);
@@ -733,7 +735,7 @@ tcp_usr_rcvd(struct socket *so, int flags)
}
tp = intotcpcb(inp);
TCPDEBUG1();
- tcp_output(tp);
+ tcp_output_rcvd(tp);
out:
TCPDEBUG2(PRU_RCVD);
@@ -838,7 +840,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
if (tp != NULL) {
if (flags & PRUS_MORETOCOME)
tp->t_flags |= TF_MORETOCOME;
- error = tcp_output(tp);
+ error = tcp_output_send(tp);
if (flags & PRUS_MORETOCOME)
tp->t_flags &= ~TF_MORETOCOME;
}
@@ -889,7 +891,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
}
tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
tp->t_flags |= TF_FORCEDATA;
- error = tcp_output(tp);
+ error = tcp_output_send(tp);
tp->t_flags &= ~TF_FORCEDATA;
}
out:
@@ -1489,7 +1491,7 @@ tcp_disconnect(struct tcpcb *tp)
sbflush(&so->so_rcv);
tcp_usrclosed(tp);
if (!(inp->inp_vflag & INP_DROPPED))
- tcp_output(tp);
+ tcp_output_disconnect(tp);
}
}
@@ -1511,8 +1513,10 @@ tcp_usrclosed(struct tcpcb *tp)
INP_LOCK_ASSERT(tp->t_inpcb);
switch (tp->t_state) {
- case TCPS_CLOSED:
case TCPS_LISTEN:
+ tcp_offload_listen_close(tp);
+ /* FALLTHROUGH */
+ case TCPS_CLOSED:
tp->t_state = TCPS_CLOSED;
tp = tcp_close(tp);
/*
OpenPOWER on IntegriCloud