sctp_lock_userspace.h (7384B)
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 #ifndef _NETINET_SCTP_LOCK_EMPTY_H_ 37 #define _NETINET_SCTP_LOCK_EMPTY_H_ 38 39 /* 40 * Empty Lock declarations for all other platforms. Pre-process away to 41 * nothing. 42 */ 43 44 /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/ 45 46 #define SCTP_IPI_COUNT_INIT() 47 48 #define SCTP_STATLOG_INIT_LOCK() 49 #define SCTP_STATLOG_LOCK() 50 #define SCTP_STATLOG_UNLOCK() 51 #define SCTP_STATLOG_DESTROY() 52 53 #define SCTP_INP_INFO_LOCK_DESTROY() 54 55 #define SCTP_INP_INFO_LOCK_INIT() 56 #define SCTP_INP_INFO_RLOCK() 57 #define SCTP_INP_INFO_WLOCK() 58 #define SCTP_INP_INFO_TRYLOCK() 1 59 #define SCTP_INP_INFO_RUNLOCK() 60 #define SCTP_INP_INFO_WUNLOCK() 61 #define SCTP_INP_INFO_LOCK_ASSERT() 62 #define SCTP_INP_INFO_RLOCK_ASSERT() 63 #define SCTP_INP_INFO_WLOCK_ASSERT() 64 65 #define SCTP_WQ_ADDR_INIT() 66 #define SCTP_WQ_ADDR_DESTROY() 67 #define SCTP_WQ_ADDR_LOCK() 68 #define SCTP_WQ_ADDR_UNLOCK() 69 #define SCTP_WQ_ADDR_LOCK_ASSERT() 70 71 #define SCTP_IPI_ADDR_INIT() 72 #define SCTP_IPI_ADDR_DESTROY() 73 #define SCTP_IPI_ADDR_RLOCK() 74 #define SCTP_IPI_ADDR_WLOCK() 75 #define SCTP_IPI_ADDR_RUNLOCK() 76 #define SCTP_IPI_ADDR_WUNLOCK() 77 #define SCTP_IPI_ADDR_LOCK_ASSERT() 78 #define SCTP_IPI_ADDR_WLOCK_ASSERT() 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_LOCK_INIT(_inp) 91 #define SCTP_INP_READ_LOCK_DESTROY(_inp) 92 #define SCTP_INP_READ_LOCK(_inp) 93 #define SCTP_INP_READ_UNLOCK(_inp) 94 #define SCTP_INP_READ_LOCK_ASSERT(_inp) 95 96 #define SCTP_INP_LOCK_INIT(_inp) 97 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) 98 #define SCTP_INP_LOCK_DESTROY(_inp) 99 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) 100 101 #define SCTP_INP_RLOCK(_inp) 102 #define SCTP_INP_WLOCK(_inp) 103 #define SCTP_INP_RLOCK_ASSERT(_inp) 104 #define SCTP_INP_WLOCK_ASSERT(_inp) 105 106 #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ 107 108 #define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */ 109 110 #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ 111 112 113 #define SCTP_INP_INCR_REF(_inp) 114 #define SCTP_INP_DECR_REF(_inp) 115 116 #define SCTP_ASOC_CREATE_LOCK(_inp) 117 118 #define SCTP_INP_RUNLOCK(_inp) 119 #define SCTP_INP_WUNLOCK(_inp) 120 #define SCTP_ASOC_CREATE_UNLOCK(_inp) 121 122 123 #define SCTP_TCB_LOCK_INIT(_tcb) 124 #define SCTP_TCB_LOCK_DESTROY(_tcb) 125 #define SCTP_TCB_LOCK(_tcb) 126 #define SCTP_TCB_TRYLOCK(_tcb) 1 127 #define SCTP_TCB_UNLOCK(_tcb) 128 #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) 129 #define SCTP_TCB_LOCK_ASSERT(_tcb) 130 131 132 133 #define SCTP_ITERATOR_LOCK_INIT() 134 #define SCTP_ITERATOR_LOCK() 135 #define SCTP_ITERATOR_UNLOCK() 136 #define SCTP_ITERATOR_LOCK_DESTROY() 137 138 139 140 #define SCTP_INCR_EP_COUNT() \ 141 do { \ 142 sctppcbinfo.ipi_count_ep++; \ 143 } while (0) 144 145 #define SCTP_DECR_EP_COUNT() \ 146 do { \ 147 sctppcbinfo.ipi_count_ep--; \ 148 } while (0) 149 150 #define SCTP_INCR_ASOC_COUNT() \ 151 do { \ 152 sctppcbinfo.ipi_count_asoc++; \ 153 } while (0) 154 155 #define SCTP_DECR_ASOC_COUNT() \ 156 do { \ 157 sctppcbinfo.ipi_count_asoc--; \ 158 } while (0) 159 160 #define SCTP_INCR_LADDR_COUNT() \ 161 do { \ 162 sctppcbinfo.ipi_count_laddr++; \ 163 } while (0) 164 165 #define SCTP_DECR_LADDR_COUNT() \ 166 do { \ 167 sctppcbinfo.ipi_count_laddr--; \ 168 } while (0) 169 170 #define SCTP_INCR_RADDR_COUNT() \ 171 do { \ 172 sctppcbinfo.ipi_count_raddr++; \ 173 } while (0) 174 175 #define SCTP_DECR_RADDR_COUNT() \ 176 do { \ 177 sctppcbinfo.ipi_count_raddr--; \ 178 } while (0) 179 180 #define SCTP_INCR_CHK_COUNT() \ 181 do { \ 182 sctppcbinfo.ipi_count_chunk++; \ 183 } while (0) 184 185 #define SCTP_DECR_CHK_COUNT() \ 186 do { \ 187 sctppcbinfo.ipi_count_chunk--; \ 188 } while (0) 189 190 #define SCTP_INCR_READQ_COUNT() \ 191 do { \ 192 sctppcbinfo.ipi_count_readq++; \ 193 } while (0) 194 195 #define SCTP_DECR_READQ_COUNT() \ 196 do { \ 197 sctppcbinfo.ipi_count_readq--; \ 198 } while (0) 199 200 #define SCTP_INCR_STRMOQ_COUNT() \ 201 do { \ 202 sctppcbinfo.ipi_count_strmoq++; \ 203 } while (0) 204 205 #define SCTP_DECR_STRMOQ_COUNT() \ 206 do { \ 207 sctppcbinfo.ipi_count_strmoq--; \ 208 } while (0) 209 210 211 /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */ 212 #if 0 213 #define SCTP_IPI_ADDR_LOCK() 214 #define SCTP_IPI_ADDR_UNLOCK() 215 #endif 216 217 218 /* These were in sctp_lock_empty.h because they were commented out within 219 * within user_include/user_socketvar.h . If they are NOT commented out 220 * in user_socketvar.h (because that seems the more natural place for them 221 * to live), then change this "if" to 0. Keep the "if" as 1 if these ARE 222 * indeed commented out in user_socketvar.h . 223 * 224 * This modularity is kept so this file can easily be chosen as an alternative 225 * to SCTP_PROCESS_LEVEL_LOCKS. If one defines SCTP_PROCESS_LEVEL_LOCKS in 226 * user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't 227 * implement) is used, and that declares these locks already (so using 228 * SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out 229 * in user_socketvar.h). 230 */ 231 #if 1 232 #define SOCK_LOCK(_so) 233 #define SOCK_UNLOCK(_so) 234 #define SOCKBUF_LOCK(_so_buf) 235 #define SOCKBUF_UNLOCK(_so_buf) 236 #define SOCKBUF_LOCK_ASSERT(_so_buf) 237 #endif 238 239 #endif