michael@0: /*- michael@0: * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. michael@0: * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. michael@0: * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. michael@0: * Copyright (c) 2008-2012, by Brad Penoff. All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions are met: michael@0: * michael@0: * a) Redistributions of source code must retain the above copyright notice, michael@0: * this list of conditions and the following disclaimer. michael@0: * michael@0: * b) Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in michael@0: * the documentation and/or other materials provided with the distribution. michael@0: * michael@0: * c) Neither the name of Cisco Systems, Inc. nor the names of its michael@0: * contributors may be used to endorse or promote products derived michael@0: * from this software without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, michael@0: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE michael@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE michael@0: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR michael@0: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF michael@0: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS michael@0: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN michael@0: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) michael@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF michael@0: * THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: michael@0: #ifdef __FreeBSD__ michael@0: #include michael@0: __FBSDID("$FreeBSD$"); michael@0: #endif michael@0: michael@0: #ifndef _NETINET_SCTP_LOCK_EMPTY_H_ michael@0: #define _NETINET_SCTP_LOCK_EMPTY_H_ michael@0: michael@0: /* michael@0: * Empty Lock declarations for all other platforms. Pre-process away to michael@0: * nothing. michael@0: */ michael@0: michael@0: /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/ michael@0: michael@0: #define SCTP_IPI_COUNT_INIT() michael@0: michael@0: #define SCTP_STATLOG_INIT_LOCK() michael@0: #define SCTP_STATLOG_LOCK() michael@0: #define SCTP_STATLOG_UNLOCK() michael@0: #define SCTP_STATLOG_DESTROY() michael@0: michael@0: #define SCTP_INP_INFO_LOCK_DESTROY() michael@0: michael@0: #define SCTP_INP_INFO_LOCK_INIT() michael@0: #define SCTP_INP_INFO_RLOCK() michael@0: #define SCTP_INP_INFO_WLOCK() michael@0: #define SCTP_INP_INFO_TRYLOCK() 1 michael@0: #define SCTP_INP_INFO_RUNLOCK() michael@0: #define SCTP_INP_INFO_WUNLOCK() michael@0: michael@0: #define SCTP_WQ_ADDR_INIT() michael@0: #define SCTP_WQ_ADDR_DESTROY() michael@0: #define SCTP_WQ_ADDR_LOCK() michael@0: #define SCTP_WQ_ADDR_UNLOCK() michael@0: michael@0: michael@0: #define SCTP_IPI_ADDR_INIT() michael@0: #define SCTP_IPI_ADDR_DESTROY() michael@0: #define SCTP_IPI_ADDR_RLOCK() michael@0: #define SCTP_IPI_ADDR_WLOCK() michael@0: #define SCTP_IPI_ADDR_RUNLOCK() michael@0: #define SCTP_IPI_ADDR_WUNLOCK() michael@0: michael@0: #define SCTP_IPI_ITERATOR_WQ_INIT() michael@0: #define SCTP_IPI_ITERATOR_WQ_DESTROY() michael@0: #define SCTP_IPI_ITERATOR_WQ_LOCK() michael@0: #define SCTP_IPI_ITERATOR_WQ_UNLOCK() michael@0: michael@0: michael@0: #define SCTP_IP_PKTLOG_INIT() michael@0: #define SCTP_IP_PKTLOG_LOCK() michael@0: #define SCTP_IP_PKTLOG_UNLOCK() michael@0: #define SCTP_IP_PKTLOG_DESTROY() michael@0: michael@0: michael@0: michael@0: #define SCTP_INP_READ_INIT(_inp) michael@0: #define SCTP_INP_READ_DESTROY(_inp) michael@0: #define SCTP_INP_READ_LOCK(_inp) michael@0: #define SCTP_INP_READ_UNLOCK(_inp) michael@0: michael@0: #define SCTP_INP_LOCK_INIT(_inp) michael@0: #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) michael@0: #define SCTP_INP_LOCK_DESTROY(_inp) michael@0: #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) michael@0: michael@0: michael@0: #define SCTP_INP_RLOCK(_inp) michael@0: #define SCTP_INP_WLOCK(_inp) michael@0: michael@0: #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ michael@0: michael@0: #define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */ michael@0: michael@0: #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ michael@0: michael@0: michael@0: #define SCTP_TCB_SEND_LOCK_INIT(_tcb) michael@0: #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) michael@0: #define SCTP_TCB_SEND_LOCK(_tcb) michael@0: #define SCTP_TCB_SEND_UNLOCK(_tcb) michael@0: michael@0: #define SCTP_INP_INCR_REF(_inp) michael@0: #define SCTP_INP_DECR_REF(_inp) michael@0: michael@0: #define SCTP_ASOC_CREATE_LOCK(_inp) michael@0: michael@0: #define SCTP_INP_RUNLOCK(_inp) michael@0: #define SCTP_INP_WUNLOCK(_inp) michael@0: #define SCTP_ASOC_CREATE_UNLOCK(_inp) michael@0: michael@0: michael@0: #define SCTP_TCB_LOCK_INIT(_tcb) michael@0: #define SCTP_TCB_LOCK_DESTROY(_tcb) michael@0: #define SCTP_TCB_LOCK(_tcb) michael@0: #define SCTP_TCB_TRYLOCK(_tcb) 1 michael@0: #define SCTP_TCB_UNLOCK(_tcb) michael@0: #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) michael@0: #define SCTP_TCB_LOCK_ASSERT(_tcb) michael@0: michael@0: michael@0: michael@0: #define SCTP_ITERATOR_LOCK_INIT() michael@0: #define SCTP_ITERATOR_LOCK() michael@0: #define SCTP_ITERATOR_UNLOCK() michael@0: #define SCTP_ITERATOR_LOCK_DESTROY() michael@0: michael@0: michael@0: michael@0: #define SCTP_INCR_EP_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_ep++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_EP_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_ep--; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_INCR_ASOC_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_asoc++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_ASOC_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_asoc--; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_INCR_LADDR_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_laddr++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_LADDR_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_laddr--; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_INCR_RADDR_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_raddr++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_RADDR_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_raddr--; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_INCR_CHK_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_chunk++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_CHK_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_chunk--; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_INCR_READQ_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_readq++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_READQ_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_readq--; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_INCR_STRMOQ_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_strmoq++; \ michael@0: } while (0) michael@0: michael@0: #define SCTP_DECR_STRMOQ_COUNT() \ michael@0: do { \ michael@0: sctppcbinfo.ipi_count_strmoq--; \ michael@0: } while (0) michael@0: michael@0: michael@0: /* not sure if __Userspace__ needs these (but copied nonetheless...) */ michael@0: #if defined(SCTP_SO_LOCK_TESTING) michael@0: #define SCTP_INP_SO(sctpinp) (sctpinp)->ip_inp.inp.inp_socket michael@0: #define SCTP_SOCKET_LOCK(so, refcnt) michael@0: #define SCTP_SOCKET_UNLOCK(so, refcnt) michael@0: #endif michael@0: michael@0: michael@0: /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */ michael@0: #if 0 michael@0: #define SCTP_IPI_ADDR_LOCK() michael@0: #define SCTP_IPI_ADDR_UNLOCK() michael@0: #endif michael@0: michael@0: michael@0: /* These were in sctp_lock_empty.h because they were commented out within michael@0: * within user_include/user_socketvar.h . If they are NOT commented out michael@0: * in user_socketvar.h (because that seems the more natural place for them michael@0: * to live), then change this "if" to 0. Keep the "if" as 1 if these ARE michael@0: * indeed commented out in user_socketvar.h . michael@0: * michael@0: * This modularity is kept so this file can easily be chosen as an alternative michael@0: * to SCTP_PROCESS_LEVEL_LOCKS. If one defines SCTP_PROCESS_LEVEL_LOCKS in michael@0: * user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't michael@0: * implement) is used, and that declares these locks already (so using michael@0: * SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out michael@0: * in user_socketvar.h). michael@0: */ michael@0: #if 1 michael@0: #define SOCK_LOCK(_so) michael@0: #define SOCK_UNLOCK(_so) michael@0: #define SOCKBUF_LOCK(_so_buf) michael@0: #define SOCKBUF_UNLOCK(_so_buf) michael@0: #define SOCKBUF_LOCK_ASSERT(_so_buf) michael@0: #endif michael@0: michael@0: #endif