#ifndef _NETINET_TCP_OFLD_H_ #define _NETINET_TCP_OFLD_H_ #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); 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) { int error; struct tcpcb *tp = sototcpcb(so); if (!SO_OFFLOADABLE(so) || (error = ofld_connect(so, nam)) != 0) error = tcp_output(tp); else printf("connection offloaded\n"); return (error); } static __inline int tcp_gen_disconnect(struct tcpcb *tp) { int error; if (tp_offload(tp)) error = ofld_disconnect(tp); else error = tcp_output(tp); return (error); } static __inline int tcp_gen_abort(struct tcpcb *tp) { int error; if (tp_offload(tp)) error = ofld_abort(tp); else error = tcp_output(tp); return (error); } static __inline int tcp_gen_send(struct tcpcb *tp) { int error; if (tp_offload(tp)) error = ofld_send(tp); else error = tcp_output(tp); return (error); } static __inline int tcp_gen_rcvd(struct tcpcb *tp) { int error; if (tp_offload(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) { return tcp_output(tp); } static __inline void tcp_gen_listen_open(struct tcpcb *tp) {} static __inline void tcp_gen_listen_close(struct tcpcb *tp) {} #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); }; #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