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
This commit is contained in:
parent
10c2b8e128
commit
bc65987ade
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174757
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user