James Kuszmaul | 4cb043c | 2021-01-17 11:25:51 -0800 | [diff] [blame^] | 1 | /*- |
| 2 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. |
| 3 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. |
| 4 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. |
| 5 | * Copyright (c) 2008-2012, by Brad Penoff. All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions are met: |
| 9 | * |
| 10 | * a) Redistributions of source code must retain the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer. |
| 12 | * |
| 13 | * b) Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in |
| 15 | * the documentation and/or other materials provided with the distribution. |
| 16 | * |
| 17 | * c) Neither the name of Cisco Systems, Inc. nor the names of its |
| 18 | * contributors may be used to endorse or promote products derived |
| 19 | * from this software without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | */ |
| 33 | |
| 34 | #ifdef __FreeBSD__ |
| 35 | #include <sys/cdefs.h> |
| 36 | __FBSDID("$FreeBSD$"); |
| 37 | #endif |
| 38 | |
| 39 | #ifndef _NETINET_SCTP_LOCK_EMPTY_H_ |
| 40 | #define _NETINET_SCTP_LOCK_EMPTY_H_ |
| 41 | |
| 42 | /* |
| 43 | * Empty Lock declarations for all other platforms. Pre-process away to |
| 44 | * nothing. |
| 45 | */ |
| 46 | |
| 47 | /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/ |
| 48 | |
| 49 | #define SCTP_IPI_COUNT_INIT() |
| 50 | |
| 51 | #define SCTP_STATLOG_INIT_LOCK() |
| 52 | #define SCTP_STATLOG_LOCK() |
| 53 | #define SCTP_STATLOG_UNLOCK() |
| 54 | #define SCTP_STATLOG_DESTROY() |
| 55 | |
| 56 | #define SCTP_INP_INFO_LOCK_DESTROY() |
| 57 | |
| 58 | #define SCTP_INP_INFO_LOCK_INIT() |
| 59 | #define SCTP_INP_INFO_RLOCK() |
| 60 | #define SCTP_INP_INFO_WLOCK() |
| 61 | #define SCTP_INP_INFO_TRYLOCK() 1 |
| 62 | #define SCTP_INP_INFO_RUNLOCK() |
| 63 | #define SCTP_INP_INFO_WUNLOCK() |
| 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 | |
| 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 | |
| 78 | #define SCTP_IPI_ITERATOR_WQ_INIT() |
| 79 | #define SCTP_IPI_ITERATOR_WQ_DESTROY() |
| 80 | #define SCTP_IPI_ITERATOR_WQ_LOCK() |
| 81 | #define SCTP_IPI_ITERATOR_WQ_UNLOCK() |
| 82 | |
| 83 | |
| 84 | #define SCTP_IP_PKTLOG_INIT() |
| 85 | #define SCTP_IP_PKTLOG_LOCK() |
| 86 | #define SCTP_IP_PKTLOG_UNLOCK() |
| 87 | #define SCTP_IP_PKTLOG_DESTROY() |
| 88 | |
| 89 | |
| 90 | |
| 91 | #define SCTP_INP_READ_INIT(_inp) |
| 92 | #define SCTP_INP_READ_DESTROY(_inp) |
| 93 | #define SCTP_INP_READ_LOCK(_inp) |
| 94 | #define SCTP_INP_READ_UNLOCK(_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 | |
| 102 | #define SCTP_INP_RLOCK(_inp) |
| 103 | #define SCTP_INP_WLOCK(_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 |