---------------------------------------------------------------------- r14759: kmacy | 2008-03-25 14:45:31 -0700 add utility functions for safely calling tcp_subr routines ---------------------------------------------------------------------- === local/iwarp_crash_fix/sys/modules/cxgb/tom/Makefile ================================================================== --- local/iwarp_crash_fix/sys/modules/cxgb/tom/Makefile (revision 14758) +++ local/iwarp_crash_fix/sys/modules/cxgb/tom/Makefile (revision 14759) @@ -5,7 +5,7 @@ KMOD= tom SRCS= cxgb_tom.c cxgb_cpl_io.c cxgb_listen.c cxgb_tom_sysctl.c cxgb_cpl_socket.c -SRCS+= cxgb_ddp.c cxgb_vm.c cxgb_l2t.c +SRCS+= cxgb_ddp.c cxgb_vm.c cxgb_l2t.c cxgb_tcp_offload.c SRCS+= opt_compat.h opt_inet.h opt_inet6.h opt_ipsec.h opt_mac.h SRCS+= opt_tcpdebug.h opt_ddb.h opt_sched.h opt_global.h opt_ktr.h SRCS+= device_if.h bus_if.h pci_if.h === local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c ================================================================== --- local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c (revision 14758) +++ local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c (revision 14759) @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 2007, Chelsio Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Neither the name of the Chelsio Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + + +/* + * This file contains code as a short-term staging area before it is moved in + * to sys/netinet/tcp_offload.c + */ + +void +tcp_offload_twstart(struct tcpcb *tp) +{ + INP_INFO_WLOCK(&tcbinfo); + inp_wlock(tp->t_inpcb); + tcp_twstart(tp); + INP_INFO_WUNLOCK(&tcbinfo); +} + +struct tcpcb * +tcp_offload_close(struct tcpcb *tp) +{ + + INP_INFO_WLOCK(&tcbinfo); + INP_LOCK(tp->t_inpcb); + tp = tcp_close(tp); + INP_INFO_WUNLOCK(&tcbinfo); + if (tp) + INP_UNLOCK(tp->t_inpcb); + + return (tp); +} + +struct tcpcb * +tcp_offload_drop(struct tcpcb *tp, int error) +{ + + INP_INFO_WLOCK(&tcbinfo); + INP_LOCK(tp->t_inpcb); + tp = tcp_drop(tp, error); + INP_INFO_WUNLOCK(&tcbinfo); + if (tp) + INP_UNLOCK(tp->t_inpcb); + + return (tp); +} === local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h ================================================================== --- local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h (revision 14758) +++ local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h (revision 14759) @@ -0,0 +1,8 @@ +#ifndef CXGB_TCP_OFFLOAD_H_ +#define CXGB_TCP_OFFLOAD_H_ + +void tcp_offload_twstart(struct tcpcb *tp); +struct tcpcb *tcp_offload_close(struct tcpcb *tp); +struct tcpcb *tcp_offload_drop(struct tcpcb *tp, int error); + +#endif /* CXGB_TCP_OFFLOAD_H_ */