1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 * Copyright (c) 2008-2012, by Brad Penoff. All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are met: 11 * 12 * a) Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * b) Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the distribution. 18 * 19 * c) Neither the name of Cisco Systems, Inc. nor the names of its 20 * contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 33 * THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifdef __FreeBSD__ 37 #include <sys/cdefs.h> 38 __FBSDID("$FreeBSD$"); 39 #endif 40 41 #ifndef _NETINET_SCTP_LOCK_EMPTY_H_ 42 #define _NETINET_SCTP_LOCK_EMPTY_H_ 43 44 /* 45 * Empty Lock declarations for all other platforms. Pre-process away to 46 * nothing. 47 */ 48 49 /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/ 50 51 #define SCTP_IPI_COUNT_INIT() 52 53 #define SCTP_STATLOG_INIT_LOCK() 54 #define SCTP_STATLOG_LOCK() 55 #define SCTP_STATLOG_UNLOCK() 56 #define SCTP_STATLOG_DESTROY() 57 58 #define SCTP_INP_INFO_LOCK_DESTROY() 59 60 #define SCTP_INP_INFO_LOCK_INIT() 61 #define SCTP_INP_INFO_RLOCK() 62 #define SCTP_INP_INFO_WLOCK() 63 #define SCTP_INP_INFO_TRYLOCK() 1 64 #define SCTP_INP_INFO_RUNLOCK() 65 #define SCTP_INP_INFO_WUNLOCK() 66 67 #define SCTP_WQ_ADDR_INIT() 68 #define SCTP_WQ_ADDR_DESTROY() 69 #define SCTP_WQ_ADDR_LOCK() 70 #define SCTP_WQ_ADDR_UNLOCK() 71 #define SCTP_WQ_ADDR_LOCK_ASSERT() 72 73 #define SCTP_IPI_ADDR_INIT() 74 #define SCTP_IPI_ADDR_DESTROY() 75 #define SCTP_IPI_ADDR_RLOCK() 76 #define SCTP_IPI_ADDR_WLOCK() 77 #define SCTP_IPI_ADDR_RUNLOCK() 78 #define SCTP_IPI_ADDR_WUNLOCK() 79 80 #define SCTP_IPI_ITERATOR_WQ_INIT() 81 #define SCTP_IPI_ITERATOR_WQ_DESTROY() 82 #define SCTP_IPI_ITERATOR_WQ_LOCK() 83 #define SCTP_IPI_ITERATOR_WQ_UNLOCK() 84 85 #define SCTP_IP_PKTLOG_INIT() 86 #define SCTP_IP_PKTLOG_LOCK() 87 #define SCTP_IP_PKTLOG_UNLOCK() 88 #define SCTP_IP_PKTLOG_DESTROY() 89 90 #define SCTP_INP_READ_INIT(_inp) 91 #define SCTP_INP_READ_DESTROY(_inp) 92 #define SCTP_INP_READ_LOCK(_inp) 93 #define SCTP_INP_READ_UNLOCK(_inp) 94 95 #define SCTP_INP_LOCK_INIT(_inp) 96 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) 97 #define SCTP_INP_LOCK_DESTROY(_inp) 98 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) 99 100 #define SCTP_INP_RLOCK(_inp) 101 #define SCTP_INP_WLOCK(_inp) 102 #define SCTP_INP_RLOCK_ASSERT(_inp) 103 #define SCTP_INP_WLOCK_ASSERT(_inp) 104 105 #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ 106 107 #define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */ 108 109 #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ 110 111 112 #define SCTP_TCB_SEND_LOCK_INIT(_tcb) 113 #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) 114 #define SCTP_TCB_SEND_LOCK(_tcb) 115 #define SCTP_TCB_SEND_UNLOCK(_tcb) 116 117 #define SCTP_INP_INCR_REF(_inp) 118 #define SCTP_INP_DECR_REF(_inp) 119 120 #define SCTP_ASOC_CREATE_LOCK(_inp) 121 122 #define SCTP_INP_RUNLOCK(_inp) 123 #define SCTP_INP_WUNLOCK(_inp) 124 #define SCTP_ASOC_CREATE_UNLOCK(_inp) 125 126 127 #define SCTP_TCB_LOCK_INIT(_tcb) 128 #define SCTP_TCB_LOCK_DESTROY(_tcb) 129 #define SCTP_TCB_LOCK(_tcb) 130 #define SCTP_TCB_TRYLOCK(_tcb) 1 131 #define SCTP_TCB_UNLOCK(_tcb) 132 #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) 133 #define SCTP_TCB_LOCK_ASSERT(_tcb) 134 135 136 137 #define SCTP_ITERATOR_LOCK_INIT() 138 #define SCTP_ITERATOR_LOCK() 139 #define SCTP_ITERATOR_UNLOCK() 140 #define SCTP_ITERATOR_LOCK_DESTROY() 141 142 143 144 #define SCTP_INCR_EP_COUNT() \ 145 do { \ 146 sctppcbinfo.ipi_count_ep++; \ 147 } while (0) 148 149 #define SCTP_DECR_EP_COUNT() \ 150 do { \ 151 sctppcbinfo.ipi_count_ep--; \ 152 } while (0) 153 154 #define SCTP_INCR_ASOC_COUNT() \ 155 do { \ 156 sctppcbinfo.ipi_count_asoc++; \ 157 } while (0) 158 159 #define SCTP_DECR_ASOC_COUNT() \ 160 do { \ 161 sctppcbinfo.ipi_count_asoc--; \ 162 } while (0) 163 164 #define SCTP_INCR_LADDR_COUNT() \ 165 do { \ 166 sctppcbinfo.ipi_count_laddr++; \ 167 } while (0) 168 169 #define SCTP_DECR_LADDR_COUNT() \ 170 do { \ 171 sctppcbinfo.ipi_count_laddr--; \ 172 } while (0) 173 174 #define SCTP_INCR_RADDR_COUNT() \ 175 do { \ 176 sctppcbinfo.ipi_count_raddr++; \ 177 } while (0) 178 179 #define SCTP_DECR_RADDR_COUNT() \ 180 do { \ 181 sctppcbinfo.ipi_count_raddr--; \ 182 } while (0) 183 184 #define SCTP_INCR_CHK_COUNT() \ 185 do { \ 186 sctppcbinfo.ipi_count_chunk++; \ 187 } while (0) 188 189 #define SCTP_DECR_CHK_COUNT() \ 190 do { \ 191 sctppcbinfo.ipi_count_chunk--; \ 192 } while (0) 193 194 #define SCTP_INCR_READQ_COUNT() \ 195 do { \ 196 sctppcbinfo.ipi_count_readq++; \ 197 } while (0) 198 199 #define SCTP_DECR_READQ_COUNT() \ 200 do { \ 201 sctppcbinfo.ipi_count_readq--; \ 202 } while (0) 203 204 #define SCTP_INCR_STRMOQ_COUNT() \ 205 do { \ 206 sctppcbinfo.ipi_count_strmoq++; \ 207 } while (0) 208 209 #define SCTP_DECR_STRMOQ_COUNT() \ 210 do { \ 211 sctppcbinfo.ipi_count_strmoq--; \ 212 } while (0) 213 214 215 /* not sure if __Userspace__ needs these (but copied nonetheless...) */ 216 #if defined(SCTP_SO_LOCK_TESTING) 217 #define SCTP_INP_SO(sctpinp) (sctpinp)->ip_inp.inp.inp_socket 218 #define SCTP_SOCKET_LOCK(so, refcnt) 219 #define SCTP_SOCKET_UNLOCK(so, refcnt) 220 #endif 221 222 223 /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */ 224 #if 0 225 #define SCTP_IPI_ADDR_LOCK() 226 #define SCTP_IPI_ADDR_UNLOCK() 227 #endif 228 229 230 /* These were in sctp_lock_empty.h because they were commented out within 231 * within user_include/user_socketvar.h . If they are NOT commented out 232 * in user_socketvar.h (because that seems the more natural place for them 233 * to live), then change this "if" to 0. Keep the "if" as 1 if these ARE 234 * indeed commented out in user_socketvar.h . 235 * 236 * This modularity is kept so this file can easily be chosen as an alternative 237 * to SCTP_PROCESS_LEVEL_LOCKS. If one defines SCTP_PROCESS_LEVEL_LOCKS in 238 * user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't 239 * implement) is used, and that declares these locks already (so using 240 * SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out 241 * in user_socketvar.h). 242 */ 243 #if 1 244 #define SOCK_LOCK(_so) 245 #define SOCK_UNLOCK(_so) 246 #define SOCKBUF_LOCK(_so_buf) 247 #define SOCKBUF_UNLOCK(_so_buf) 248 #define SOCKBUF_LOCK_ASSERT(_so_buf) 249 #endif 250 251 #endif 252