Index: tcp_offload.h =================================================================== RCS file: /home/kmacy/devel/ncvs/src/sys/netinet/tcp_offload.h,v retrieving revision 1.1 diff -d -u -r1.1 tcp_offload.h --- tcp_offload.h 17 Dec 2007 07:56:27 -0000 1.1 +++ tcp_offload.h 18 Dec 2007 22:41:54 -0000 @@ -216,8 +216,10 @@ 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 @@ #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 @@ } static __inline int -tcp_gen_send(struct tcpcb *tp) +tcp_output_send(struct tcpcb *tp) { #ifndef TCP_OFFLOAD_DISABLE @@ -262,7 +264,7 @@ } static __inline int -tcp_gen_rcvd(struct tcpcb *tp) +tcp_output_rcvd(struct tcpcb *tp) { #ifndef TCP_OFFLOAD_DISABLE @@ -273,7 +275,7 @@ } static __inline int -tcp_gen_disconnect(struct tcpcb *tp) +tcp_output_disconnect(struct tcpcb *tp) { #ifndef TCP_OFFLOAD_DISABLE @@ -284,7 +286,7 @@ } static __inline int -tcp_gen_reset(struct tcpcb *tp) +tcp_output_reset(struct tcpcb *tp) { #ifndef TCP_OFFLOAD_DISABLE @@ -295,7 +297,7 @@ } static __inline void -tcp_gen_detach(struct tcpcb *tp) +tcp_offload_detach(struct tcpcb *tp) { #ifndef TCP_OFFLOAD_DISABLE @@ -305,7 +307,7 @@ } 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 @@ } static __inline void -tcp_gen_listen_close(struct tcpcb *tp) +tcp_offload_listen_close(struct tcpcb *tp) { #ifndef TCP_OFFLOAD_DISABLE Index: tcp_subr.c =================================================================== RCS file: /home/kmacy/devel/ncvs/src/sys/netinet/tcp_subr.c,v retrieving revision 1.303 diff -d -u -r1.303 tcp_subr.c --- tcp_subr.c 28 Nov 2007 13:23:50 -0000 1.303 +++ tcp_subr.c 18 Dec 2007 22:11:09 -0000 @@ -85,6 +85,7 @@ #include #include #include +#include #ifdef INET6 #include #endif @@ -651,7 +652,7 @@ 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 @@ 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 @@ 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 @@ 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); } Index: tcp_usrreq.c =================================================================== RCS file: /home/kmacy/devel/ncvs/src/sys/netinet/tcp_usrreq.c,v retrieving revision 1.164 diff -d -u -r1.164 tcp_usrreq.c --- tcp_usrreq.c 19 Oct 2007 08:53:14 -0000 1.164 +++ tcp_usrreq.c 18 Dec 2007 22:11:53 -0000 @@ -85,6 +85,7 @@ #ifdef TCPDEBUG #include #endif +#include /* * TCP protocol interface to socket abstraction. @@ -385,6 +386,7 @@ if (error == 0) { tp->t_state = TCPS_LISTEN; solisten_proto(so, backlog); + tcp_offload_listen_open(tp); } SOCK_UNLOCK(so); @@ -476,7 +478,7 @@ 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 @@ 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 @@ 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 @@ TCPDEBUG1(); socantsendmore(so); tcp_usrclosed(tp); - error = tcp_output(tp); + error = tcp_output_disconnect(tp); out: TCPDEBUG2(PRU_SHUTDOWN); @@ -733,7 +735,7 @@ } tp = intotcpcb(inp); TCPDEBUG1(); - tcp_output(tp); + tcp_output_rcvd(tp); out: TCPDEBUG2(PRU_RCVD); @@ -838,7 +840,7 @@ 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 @@ } 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 @@ sbflush(&so->so_rcv); tcp_usrclosed(tp); if (!(inp->inp_vflag & INP_DROPPED)) - tcp_output(tp); + tcp_output_disconnect(tp); } } @@ -1511,8 +1513,10 @@ 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); /*