Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_offload.c
Show All 35 Lines | |||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
#include <sys/sockopt.h> | #include <sys/sockopt.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/route/nhop.h> | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/in_pcb.h> | #include <netinet/in_pcb.h> | ||||
#include <netinet/in_fib.h> | |||||
#include <netinet6/in6_fib.h> | |||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <netinet/tcp_offload.h> | #include <netinet/tcp_offload.h> | ||||
#define TCPOUTFLAGS | #define TCPOUTFLAGS | ||||
#include <netinet/tcp_fsm.h> | #include <netinet/tcp_fsm.h> | ||||
#include <netinet/tcp_var.h> | #include <netinet/tcp_var.h> | ||||
#include <netinet/toecore.h> | #include <netinet/toecore.h> | ||||
int registered_toedevs; | int registered_toedevs; | ||||
/* | /* | ||||
* Provide an opportunity for a TOE driver to offload. | * Provide an opportunity for a TOE driver to offload. | ||||
*/ | */ | ||||
int | int | ||||
tcp_offload_connect(struct socket *so, struct sockaddr *nam) | tcp_offload_connect(struct socket *so, struct sockaddr *nam) | ||||
{ | { | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct toedev *tod; | struct toedev *tod; | ||||
struct rtentry *rt; | struct nhop_object *nh; | ||||
struct epoch_tracker et; | |||||
int error = EOPNOTSUPP; | int error = EOPNOTSUPP; | ||||
INP_WLOCK_ASSERT(sotoinpcb(so)); | INP_WLOCK_ASSERT(sotoinpcb(so)); | ||||
KASSERT(nam->sa_family == AF_INET || nam->sa_family == AF_INET6, | KASSERT(nam->sa_family == AF_INET || nam->sa_family == AF_INET6, | ||||
("%s: called with sa_family %d", __func__, nam->sa_family)); | ("%s: called with sa_family %d", __func__, nam->sa_family)); | ||||
if (registered_toedevs == 0) | if (registered_toedevs == 0) | ||||
return (error); | return (error); | ||||
rt = rtalloc1(nam, 0, 0); | NET_EPOCH_ENTER(et); | ||||
if (rt) | nh = NULL; | ||||
RT_UNLOCK(rt); | if (nam->sa_family == AF_INET) | ||||
else | nh = fib4_lookup(0, ((struct sockaddr_in *)nam)->sin_addr, | ||||
NHR_NONE, 0, 0); | |||||
else if (nam->sa_family == AF_INET6) | |||||
nh = fib6_lookup(0, &((struct sockaddr_in6 *)nam)->sin6_addr, | |||||
NHR_NONE, 0, 0); | |||||
if (nh == NULL) { | |||||
NET_EPOCH_EXIT(et); | |||||
return (EHOSTUNREACH); | return (EHOSTUNREACH); | ||||
} | |||||
ifp = rt->rt_ifp; | ifp = nh->nh_ifp; | ||||
if (nam->sa_family == AF_INET && !(ifp->if_capenable & IFCAP_TOE4)) | if (nam->sa_family == AF_INET && !(ifp->if_capenable & IFCAP_TOE4)) | ||||
goto done; | goto done; | ||||
if (nam->sa_family == AF_INET6 && !(ifp->if_capenable & IFCAP_TOE6)) | if (nam->sa_family == AF_INET6 && !(ifp->if_capenable & IFCAP_TOE6)) | ||||
goto done; | goto done; | ||||
tod = TOEDEV(ifp); | tod = TOEDEV(ifp); | ||||
if (tod != NULL) | if (tod != NULL) | ||||
error = tod->tod_connect(tod, so, rt, nam); | error = tod->tod_connect(tod, so, nh, nam); | ||||
done: | done: | ||||
RTFREE(rt); | NET_EPOCH_EXIT(et); | ||||
return (error); | return (error); | ||||
} | } | ||||
void | void | ||||
tcp_offload_listen_start(struct tcpcb *tp) | tcp_offload_listen_start(struct tcpcb *tp) | ||||
{ | { | ||||
INP_WLOCK_ASSERT(tp->t_inpcb); | INP_WLOCK_ASSERT(tp->t_inpcb); | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |