netwerk/sctp/src/netinet/sctp_lock_userspace.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/sctp/src/netinet/sctp_lock_userspace.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,251 @@
     1.4 +/*-
     1.5 + * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
     1.6 + * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
     1.7 + * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
     1.8 + * Copyright (c) 2008-2012, by Brad Penoff. All rights reserved.
     1.9 + *
    1.10 + * Redistribution and use in source and binary forms, with or without
    1.11 + * modification, are permitted provided that the following conditions are met:
    1.12 + *
    1.13 + * a) Redistributions of source code must retain the above copyright notice,
    1.14 + *   this list of conditions and the following disclaimer.
    1.15 + *
    1.16 + * b) Redistributions in binary form must reproduce the above copyright
    1.17 + *    notice, this list of conditions and the following disclaimer in
    1.18 + *   the documentation and/or other materials provided with the distribution.
    1.19 + *
    1.20 + * c) Neither the name of Cisco Systems, Inc. nor the names of its
    1.21 + *    contributors may be used to endorse or promote products derived
    1.22 + *    from this software without specific prior written permission.
    1.23 + *
    1.24 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.25 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    1.26 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.27 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    1.28 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.29 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.30 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.31 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.32 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.33 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    1.34 + * THE POSSIBILITY OF SUCH DAMAGE.
    1.35 + */
    1.36 +
    1.37 +#ifdef __FreeBSD__
    1.38 +#include <sys/cdefs.h>
    1.39 +__FBSDID("$FreeBSD$");
    1.40 +#endif
    1.41 +
    1.42 +#ifndef _NETINET_SCTP_LOCK_EMPTY_H_
    1.43 +#define _NETINET_SCTP_LOCK_EMPTY_H_
    1.44 +
    1.45 +/*
    1.46 + * Empty Lock declarations for all other platforms. Pre-process away to
    1.47 + * nothing.
    1.48 + */
    1.49 +
    1.50 +/* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/
    1.51 +
    1.52 +#define SCTP_IPI_COUNT_INIT()
    1.53 +
    1.54 +#define SCTP_STATLOG_INIT_LOCK()
    1.55 +#define SCTP_STATLOG_LOCK()
    1.56 +#define SCTP_STATLOG_UNLOCK()
    1.57 +#define SCTP_STATLOG_DESTROY()
    1.58 +
    1.59 +#define SCTP_INP_INFO_LOCK_DESTROY()
    1.60 +
    1.61 +#define SCTP_INP_INFO_LOCK_INIT()
    1.62 +#define SCTP_INP_INFO_RLOCK()
    1.63 +#define SCTP_INP_INFO_WLOCK()
    1.64 +#define SCTP_INP_INFO_TRYLOCK() 1
    1.65 +#define SCTP_INP_INFO_RUNLOCK()
    1.66 +#define SCTP_INP_INFO_WUNLOCK()
    1.67 +
    1.68 +#define SCTP_WQ_ADDR_INIT()
    1.69 +#define SCTP_WQ_ADDR_DESTROY()
    1.70 +#define SCTP_WQ_ADDR_LOCK()
    1.71 +#define SCTP_WQ_ADDR_UNLOCK()
    1.72 +
    1.73 +
    1.74 +#define SCTP_IPI_ADDR_INIT()
    1.75 +#define SCTP_IPI_ADDR_DESTROY()
    1.76 +#define SCTP_IPI_ADDR_RLOCK()
    1.77 +#define SCTP_IPI_ADDR_WLOCK()
    1.78 +#define SCTP_IPI_ADDR_RUNLOCK()
    1.79 +#define SCTP_IPI_ADDR_WUNLOCK()
    1.80 +
    1.81 +#define SCTP_IPI_ITERATOR_WQ_INIT()
    1.82 +#define SCTP_IPI_ITERATOR_WQ_DESTROY()
    1.83 +#define SCTP_IPI_ITERATOR_WQ_LOCK()
    1.84 +#define SCTP_IPI_ITERATOR_WQ_UNLOCK()
    1.85 +
    1.86 +
    1.87 +#define SCTP_IP_PKTLOG_INIT()
    1.88 +#define SCTP_IP_PKTLOG_LOCK()
    1.89 +#define SCTP_IP_PKTLOG_UNLOCK()
    1.90 +#define SCTP_IP_PKTLOG_DESTROY()
    1.91 +
    1.92 +
    1.93 +
    1.94 +#define SCTP_INP_READ_INIT(_inp)
    1.95 +#define SCTP_INP_READ_DESTROY(_inp)
    1.96 +#define SCTP_INP_READ_LOCK(_inp)
    1.97 +#define SCTP_INP_READ_UNLOCK(_inp)
    1.98 +
    1.99 +#define SCTP_INP_LOCK_INIT(_inp)
   1.100 +#define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
   1.101 +#define SCTP_INP_LOCK_DESTROY(_inp)
   1.102 +#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
   1.103 +
   1.104 +
   1.105 +#define SCTP_INP_RLOCK(_inp)
   1.106 +#define SCTP_INP_WLOCK(_inp)
   1.107 +
   1.108 +#define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
   1.109 +
   1.110 +#define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */
   1.111 +
   1.112 +#define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
   1.113 +
   1.114 +
   1.115 +#define SCTP_TCB_SEND_LOCK_INIT(_tcb)
   1.116 +#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb)
   1.117 +#define SCTP_TCB_SEND_LOCK(_tcb)
   1.118 +#define SCTP_TCB_SEND_UNLOCK(_tcb)
   1.119 +
   1.120 +#define SCTP_INP_INCR_REF(_inp)
   1.121 +#define SCTP_INP_DECR_REF(_inp)
   1.122 +
   1.123 +#define SCTP_ASOC_CREATE_LOCK(_inp)
   1.124 +
   1.125 +#define SCTP_INP_RUNLOCK(_inp)
   1.126 +#define SCTP_INP_WUNLOCK(_inp)
   1.127 +#define SCTP_ASOC_CREATE_UNLOCK(_inp)
   1.128 +
   1.129 +
   1.130 +#define SCTP_TCB_LOCK_INIT(_tcb)
   1.131 +#define SCTP_TCB_LOCK_DESTROY(_tcb)
   1.132 +#define SCTP_TCB_LOCK(_tcb)
   1.133 +#define SCTP_TCB_TRYLOCK(_tcb) 1
   1.134 +#define SCTP_TCB_UNLOCK(_tcb)
   1.135 +#define SCTP_TCB_UNLOCK_IFOWNED(_tcb)
   1.136 +#define SCTP_TCB_LOCK_ASSERT(_tcb)
   1.137 +
   1.138 +
   1.139 +
   1.140 +#define SCTP_ITERATOR_LOCK_INIT()
   1.141 +#define SCTP_ITERATOR_LOCK()
   1.142 +#define SCTP_ITERATOR_UNLOCK()
   1.143 +#define SCTP_ITERATOR_LOCK_DESTROY()
   1.144 +
   1.145 +
   1.146 +
   1.147 +#define SCTP_INCR_EP_COUNT() \
   1.148 +                do { \
   1.149 +		       sctppcbinfo.ipi_count_ep++; \
   1.150 +	        } while (0)
   1.151 +
   1.152 +#define SCTP_DECR_EP_COUNT() \
   1.153 +                do { \
   1.154 +		       sctppcbinfo.ipi_count_ep--; \
   1.155 +	        } while (0)
   1.156 +
   1.157 +#define SCTP_INCR_ASOC_COUNT() \
   1.158 +                do { \
   1.159 +	               sctppcbinfo.ipi_count_asoc++; \
   1.160 +	        } while (0)
   1.161 +
   1.162 +#define SCTP_DECR_ASOC_COUNT() \
   1.163 +                do { \
   1.164 +	               sctppcbinfo.ipi_count_asoc--; \
   1.165 +	        } while (0)
   1.166 +
   1.167 +#define SCTP_INCR_LADDR_COUNT() \
   1.168 +                do { \
   1.169 +	               sctppcbinfo.ipi_count_laddr++; \
   1.170 +	        } while (0)
   1.171 +
   1.172 +#define SCTP_DECR_LADDR_COUNT() \
   1.173 +                do { \
   1.174 +	               sctppcbinfo.ipi_count_laddr--; \
   1.175 +	        } while (0)
   1.176 +
   1.177 +#define SCTP_INCR_RADDR_COUNT() \
   1.178 +                do { \
   1.179 + 	               sctppcbinfo.ipi_count_raddr++; \
   1.180 +	        } while (0)
   1.181 +
   1.182 +#define SCTP_DECR_RADDR_COUNT() \
   1.183 +                do { \
   1.184 + 	               sctppcbinfo.ipi_count_raddr--; \
   1.185 +	        } while (0)
   1.186 +
   1.187 +#define SCTP_INCR_CHK_COUNT() \
   1.188 +                do { \
   1.189 +  	               sctppcbinfo.ipi_count_chunk++; \
   1.190 +	        } while (0)
   1.191 +
   1.192 +#define SCTP_DECR_CHK_COUNT() \
   1.193 +                do { \
   1.194 +  	               sctppcbinfo.ipi_count_chunk--; \
   1.195 +	        } while (0)
   1.196 +
   1.197 +#define SCTP_INCR_READQ_COUNT() \
   1.198 +                do { \
   1.199 +		       sctppcbinfo.ipi_count_readq++; \
   1.200 +	        } while (0)
   1.201 +
   1.202 +#define SCTP_DECR_READQ_COUNT() \
   1.203 +                do { \
   1.204 +		       sctppcbinfo.ipi_count_readq--; \
   1.205 +	        } while (0)
   1.206 +
   1.207 +#define SCTP_INCR_STRMOQ_COUNT() \
   1.208 +                do { \
   1.209 +		       sctppcbinfo.ipi_count_strmoq++; \
   1.210 +	        } while (0)
   1.211 +
   1.212 +#define SCTP_DECR_STRMOQ_COUNT() \
   1.213 +                do { \
   1.214 +		       sctppcbinfo.ipi_count_strmoq--; \
   1.215 +	        } while (0)
   1.216 +
   1.217 +
   1.218 +/* not sure if __Userspace__ needs these (but copied nonetheless...) */
   1.219 +#if defined(SCTP_SO_LOCK_TESTING)
   1.220 +#define SCTP_INP_SO(sctpinp)	(sctpinp)->ip_inp.inp.inp_socket
   1.221 +#define SCTP_SOCKET_LOCK(so, refcnt)
   1.222 +#define SCTP_SOCKET_UNLOCK(so, refcnt)
   1.223 +#endif
   1.224 +
   1.225 +
   1.226 +/* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */
   1.227 +#if 0
   1.228 +#define SCTP_IPI_ADDR_LOCK()
   1.229 +#define SCTP_IPI_ADDR_UNLOCK()
   1.230 +#endif
   1.231 +
   1.232 +
   1.233 +/* These were in sctp_lock_empty.h because they were commented out within
   1.234 + *  within user_include/user_socketvar.h .  If they are NOT commented out
   1.235 + *  in user_socketvar.h (because that seems the more natural place for them
   1.236 + *  to live), then change this "if" to 0.  Keep the "if" as 1 if these ARE
   1.237 + *  indeed commented out in user_socketvar.h .
   1.238 + *
   1.239 + * This modularity is kept so this file can easily be chosen as an alternative
   1.240 + *  to SCTP_PROCESS_LEVEL_LOCKS.  If one defines SCTP_PROCESS_LEVEL_LOCKS in
   1.241 + *  user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't
   1.242 + *  implement) is used, and that declares these locks already (so using
   1.243 + *  SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out
   1.244 + *  in user_socketvar.h).
   1.245 + */
   1.246 +#if 1
   1.247 +#define SOCK_LOCK(_so)
   1.248 +#define SOCK_UNLOCK(_so)
   1.249 +#define SOCKBUF_LOCK(_so_buf)
   1.250 +#define SOCKBUF_UNLOCK(_so_buf)
   1.251 +#define SOCKBUF_LOCK_ASSERT(_so_buf)
   1.252 +#endif
   1.253 +
   1.254 +#endif

mercurial