1f8829a4aSRandall Stewart #ifndef __sctp_lock_bsd_h__ 2f8829a4aSRandall Stewart #define __sctp_lock_bsd_h__ 3f8829a4aSRandall Stewart /*- 4f8829a4aSRandall Stewart * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved. 5f8829a4aSRandall Stewart * 6f8829a4aSRandall Stewart * Redistribution and use in source and binary forms, with or without 7f8829a4aSRandall Stewart * modification, are permitted provided that the following conditions are met: 8f8829a4aSRandall Stewart * 9f8829a4aSRandall Stewart * a) Redistributions of source code must retain the above copyright notice, 10f8829a4aSRandall Stewart * this list of conditions and the following disclaimer. 11f8829a4aSRandall Stewart * 12f8829a4aSRandall Stewart * b) Redistributions in binary form must reproduce the above copyright 13f8829a4aSRandall Stewart * notice, this list of conditions and the following disclaimer in 14f8829a4aSRandall Stewart * the documentation and/or other materials provided with the distribution. 15f8829a4aSRandall Stewart * 16f8829a4aSRandall Stewart * c) Neither the name of Cisco Systems, Inc. nor the names of its 17f8829a4aSRandall Stewart * contributors may be used to endorse or promote products derived 18f8829a4aSRandall Stewart * from this software without specific prior written permission. 19f8829a4aSRandall Stewart * 20f8829a4aSRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21f8829a4aSRandall Stewart * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22f8829a4aSRandall Stewart * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23f8829a4aSRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24f8829a4aSRandall Stewart * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25f8829a4aSRandall Stewart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26f8829a4aSRandall Stewart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27f8829a4aSRandall Stewart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28f8829a4aSRandall Stewart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29f8829a4aSRandall Stewart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30f8829a4aSRandall Stewart * THE POSSIBILITY OF SUCH DAMAGE. 31f8829a4aSRandall Stewart */ 32f8829a4aSRandall Stewart 33f8829a4aSRandall Stewart /* 34f8829a4aSRandall Stewart * General locking concepts: The goal of our locking is to of course provide 35f8829a4aSRandall Stewart * consistency and yet minimize overhead. We will attempt to use 36f8829a4aSRandall Stewart * non-recursive locks which are supposed to be quite inexpensive. Now in 37f8829a4aSRandall Stewart * order to do this the goal is that most functions are not aware of locking. 38f8829a4aSRandall Stewart * Once we have a TCB we lock it and unlock when we are through. This means 39f8829a4aSRandall Stewart * that the TCB lock is kind-of a "global" lock when working on an 40f8829a4aSRandall Stewart * association. Caution must be used when asserting a TCB_LOCK since if we 41f8829a4aSRandall Stewart * recurse we deadlock. 42f8829a4aSRandall Stewart * 43f8829a4aSRandall Stewart * Most other locks (INP and INFO) attempt to localize the locking i.e. we try 44f8829a4aSRandall Stewart * to contain the lock and unlock within the function that needs to lock it. 45f8829a4aSRandall Stewart * This sometimes mean we do extra locks and unlocks and lose a bit of 46f8829a4aSRandall Stewart * efficency, but if the performance statements about non-recursive locks are 47f8829a4aSRandall Stewart * true this should not be a problem. One issue that arises with this only 48f8829a4aSRandall Stewart * lock when needed is that if an implicit association setup is done we have 49f8829a4aSRandall Stewart * a problem. If at the time I lookup an association I have NULL in the tcb 50f8829a4aSRandall Stewart * return, by the time I call to create the association some other processor 51f8829a4aSRandall Stewart * could have created it. This is what the CREATE lock on the endpoint. 52f8829a4aSRandall Stewart * Places where we will be implicitly creating the association OR just 53f8829a4aSRandall Stewart * creating an association (the connect call) will assert the CREATE_INP 54f8829a4aSRandall Stewart * lock. This will assure us that during all the lookup of INP and INFO if 55f8829a4aSRandall Stewart * another creator is also locking/looking up we can gate the two to 56f8829a4aSRandall Stewart * synchronize. So the CREATE_INP lock is also another one we must use 57f8829a4aSRandall Stewart * extreme caution in locking to make sure we don't hit a re-entrancy issue. 58f8829a4aSRandall Stewart * 59f8829a4aSRandall Stewart * For non FreeBSD 5.x we provide a bunch of EMPTY lock macros so we can 60f8829a4aSRandall Stewart * blatantly put locks everywhere and they reduce to nothing on 61f8829a4aSRandall Stewart * NetBSD/OpenBSD and FreeBSD 4.x 62f8829a4aSRandall Stewart * 63f8829a4aSRandall Stewart */ 64f8829a4aSRandall Stewart 65f8829a4aSRandall Stewart /* 66f8829a4aSRandall Stewart * When working with the global SCTP lists we lock and unlock the INP_INFO 67f8829a4aSRandall Stewart * lock. So when we go to lookup an association we will want to do a 68f8829a4aSRandall Stewart * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to 69f8829a4aSRandall Stewart * the sctppcbinfo list's we will do a SCTP_INP_INFO_WLOCK(). 70f8829a4aSRandall Stewart */ 7173932c69SRandall Stewart #include <sys/cdefs.h> 72f8829a4aSRandall Stewart __FBSDID("$FreeBSD$"); 73f8829a4aSRandall Stewart 74a5d547adSRandall Stewart 75a5d547adSRandall Stewart extern struct sctp_foo_stuff sctp_logoff[]; 76a5d547adSRandall Stewart extern int sctp_logoff_stuff; 77a5d547adSRandall Stewart 78f8829a4aSRandall Stewart #define SCTP_IPI_COUNT_INIT() 79f8829a4aSRandall Stewart 80f8829a4aSRandall Stewart #define SCTP_STATLOG_INIT_LOCK() 81f8829a4aSRandall Stewart #define SCTP_STATLOG_LOCK() 82f8829a4aSRandall Stewart #define SCTP_STATLOG_UNLOCK() 83f8829a4aSRandall Stewart #define SCTP_STATLOG_DESTROY() 84f8829a4aSRandall Stewart 85f8829a4aSRandall Stewart #define SCTP_STATLOG_GETREF(x) { \ 86f8829a4aSRandall Stewart x = atomic_fetchadd_int(&global_sctp_cwnd_log_at, 1); \ 87f8829a4aSRandall Stewart if(x == SCTP_STAT_LOG_SIZE) { \ 88f8829a4aSRandall Stewart global_sctp_cwnd_log_at = 1; \ 89f8829a4aSRandall Stewart x = 0; \ 90f8829a4aSRandall Stewart global_sctp_cwnd_log_rolled = 1; \ 91f8829a4aSRandall Stewart } \ 92f8829a4aSRandall Stewart } 93f8829a4aSRandall Stewart 94a5d547adSRandall Stewart 95f8829a4aSRandall Stewart #define SCTP_INP_INFO_LOCK_INIT() \ 96f8829a4aSRandall Stewart mtx_init(&sctppcbinfo.ipi_ep_mtx, "sctp-info", "inp_info", MTX_DEF) 97f8829a4aSRandall Stewart 98f8829a4aSRandall Stewart 99f8829a4aSRandall Stewart #define SCTP_INP_INFO_RLOCK() do { \ 100f8829a4aSRandall Stewart mtx_lock(&sctppcbinfo.ipi_ep_mtx); \ 101f8829a4aSRandall Stewart } while (0) 102f8829a4aSRandall Stewart 103f8829a4aSRandall Stewart 104f8829a4aSRandall Stewart #define SCTP_INP_INFO_WLOCK() do { \ 105f8829a4aSRandall Stewart mtx_lock(&sctppcbinfo.ipi_ep_mtx); \ 106f8829a4aSRandall Stewart } while (0) 107f8829a4aSRandall Stewart 108f8829a4aSRandall Stewart 109f8829a4aSRandall Stewart 110f8829a4aSRandall Stewart #define SCTP_IPI_ADDR_INIT() \ 111f8829a4aSRandall Stewart mtx_init(&sctppcbinfo.ipi_addr_mtx, "sctp-addr-wq", "sctp_addr_wq", MTX_DEF) 112f8829a4aSRandall Stewart 113f8829a4aSRandall Stewart #define SCTP_IPI_ADDR_DESTROY() \ 114f8829a4aSRandall Stewart mtx_destroy(&sctppcbinfo.ipi_addr_mtx) 115f8829a4aSRandall Stewart 116f8829a4aSRandall Stewart #define SCTP_IPI_ADDR_LOCK() do { \ 117f8829a4aSRandall Stewart mtx_lock(&sctppcbinfo.ipi_addr_mtx); \ 118f8829a4aSRandall Stewart } while (0) 119f8829a4aSRandall Stewart 120f8829a4aSRandall Stewart #define SCTP_IPI_ADDR_UNLOCK() mtx_unlock(&sctppcbinfo.ipi_addr_mtx) 121f8829a4aSRandall Stewart 122f8829a4aSRandall Stewart #define SCTP_INP_INFO_RUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx) 123f8829a4aSRandall Stewart #define SCTP_INP_INFO_WUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx) 124f8829a4aSRandall Stewart 125f8829a4aSRandall Stewart /* 126f8829a4aSRandall Stewart * The INP locks we will use for locking an SCTP endpoint, so for example if 127f8829a4aSRandall Stewart * we want to change something at the endpoint level for example random_store 128f8829a4aSRandall Stewart * or cookie secrets we lock the INP level. 129f8829a4aSRandall Stewart */ 130f8829a4aSRandall Stewart 131f8829a4aSRandall Stewart #define SCTP_INP_READ_INIT(_inp) \ 132f8829a4aSRandall Stewart mtx_init(&(_inp)->inp_rdata_mtx, "sctp-read", "inpr", MTX_DEF | MTX_DUPOK) 133f8829a4aSRandall Stewart 134f8829a4aSRandall Stewart #define SCTP_INP_READ_DESTROY(_inp) \ 135f8829a4aSRandall Stewart mtx_destroy(&(_inp)->inp_rdata_mtx) 136f8829a4aSRandall Stewart 137f8829a4aSRandall Stewart #define SCTP_INP_READ_LOCK(_inp) do { \ 138f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_rdata_mtx); \ 139f8829a4aSRandall Stewart } while (0) 140f8829a4aSRandall Stewart 141f8829a4aSRandall Stewart 142f8829a4aSRandall Stewart #define SCTP_INP_READ_UNLOCK(_inp) mtx_unlock(&(_inp)->inp_rdata_mtx) 143f8829a4aSRandall Stewart 144f8829a4aSRandall Stewart 145f8829a4aSRandall Stewart #define SCTP_INP_LOCK_INIT(_inp) \ 146f8829a4aSRandall Stewart mtx_init(&(_inp)->inp_mtx, "sctp-inp", "inp", MTX_DEF | MTX_DUPOK) 147f8829a4aSRandall Stewart #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \ 148f8829a4aSRandall Stewart mtx_init(&(_inp)->inp_create_mtx, "sctp-create", "inp_create", \ 149f8829a4aSRandall Stewart MTX_DEF | MTX_DUPOK) 150f8829a4aSRandall Stewart 151f8829a4aSRandall Stewart #define SCTP_INP_LOCK_DESTROY(_inp) \ 152f8829a4aSRandall Stewart mtx_destroy(&(_inp)->inp_mtx) 153f8829a4aSRandall Stewart 154f8829a4aSRandall Stewart #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) \ 155f8829a4aSRandall Stewart mtx_destroy(&(_inp)->inp_create_mtx) 156f8829a4aSRandall Stewart 157f8829a4aSRandall Stewart 158f8829a4aSRandall Stewart #ifdef SCTP_LOCK_LOGGING 159f8829a4aSRandall Stewart #define SCTP_INP_RLOCK(_inp) do { \ 160f8829a4aSRandall Stewart sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\ 161f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_mtx); \ 162f8829a4aSRandall Stewart } while (0) 163f8829a4aSRandall Stewart 164f8829a4aSRandall Stewart #define SCTP_INP_WLOCK(_inp) do { \ 165f8829a4aSRandall Stewart sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\ 166f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_mtx); \ 167f8829a4aSRandall Stewart } while (0) 168f8829a4aSRandall Stewart 169f8829a4aSRandall Stewart #else 170f8829a4aSRandall Stewart 171f8829a4aSRandall Stewart #define SCTP_INP_RLOCK(_inp) do { \ 172f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_mtx); \ 173f8829a4aSRandall Stewart } while (0) 174f8829a4aSRandall Stewart 175f8829a4aSRandall Stewart #define SCTP_INP_WLOCK(_inp) do { \ 176f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_mtx); \ 177f8829a4aSRandall Stewart } while (0) 178f8829a4aSRandall Stewart 179f8829a4aSRandall Stewart #endif 180f8829a4aSRandall Stewart 181f8829a4aSRandall Stewart 182f8829a4aSRandall Stewart #define SCTP_TCB_SEND_LOCK_INIT(_tcb) \ 183f8829a4aSRandall Stewart mtx_init(&(_tcb)->tcb_send_mtx, "sctp-send-tcb", "tcbs", MTX_DEF | MTX_DUPOK) 184f8829a4aSRandall Stewart 185f8829a4aSRandall Stewart #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_send_mtx) 186f8829a4aSRandall Stewart 187f8829a4aSRandall Stewart #define SCTP_TCB_SEND_LOCK(_tcb) do { \ 188f8829a4aSRandall Stewart mtx_lock(&(_tcb)->tcb_send_mtx); \ 189f8829a4aSRandall Stewart } while (0) 190f8829a4aSRandall Stewart 191f8829a4aSRandall Stewart #define SCTP_TCB_SEND_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_send_mtx) 192f8829a4aSRandall Stewart 193a5d547adSRandall Stewart #ifdef INVARIANTS 194a5d547adSRandall Stewart 195a5d547adSRandall Stewart #define SCTP_INP_INCR_REF(_inp) { int x; \ 196a5d547adSRandall Stewart atomic_add_int(&((_inp)->refcount), 1); \ 197a5d547adSRandall Stewart x = atomic_fetchadd_int(&sctp_logoff_stuff, 1); \ 198a5d547adSRandall Stewart if(x == 30000) \ 199a5d547adSRandall Stewart sctp_logoff_stuff = x = 0; \ 200a5d547adSRandall Stewart sctp_logoff[x].inp = _inp; \ 201a5d547adSRandall Stewart sctp_logoff[x].ticks = ticks; \ 202a5d547adSRandall Stewart sctp_logoff[x].lineno = __LINE__; \ 203a5d547adSRandall Stewart sctp_logoff[x].updown = 1; \ 204a5d547adSRandall Stewart } 205a5d547adSRandall Stewart 206a5d547adSRandall Stewart #define SCTP_INP_DECR_REF(_inp) { int x; \ 207a5d547adSRandall Stewart if (atomic_fetchadd_int(&((_inp)->refcount), -1) == 0 ) panic("refcount goes negative"); \ 208a5d547adSRandall Stewart x = atomic_fetchadd_int(&sctp_logoff_stuff, 1); \ 209a5d547adSRandall Stewart if(x == 30000) \ 210a5d547adSRandall Stewart sctp_logoff_stuff = x = 0; \ 211a5d547adSRandall Stewart sctp_logoff[x].inp = _inp; \ 212a5d547adSRandall Stewart sctp_logoff[x].ticks = ticks; \ 213a5d547adSRandall Stewart sctp_logoff[x].lineno = __LINE__; \ 214a5d547adSRandall Stewart sctp_logoff[x].updown = 0; \ 215a5d547adSRandall Stewart } 216a5d547adSRandall Stewart 217a5d547adSRandall Stewart #else 218f8829a4aSRandall Stewart 219f8829a4aSRandall Stewart #define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1) 220f8829a4aSRandall Stewart #define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1) 221f8829a4aSRandall Stewart 222a5d547adSRandall Stewart #endif 223a5d547adSRandall Stewart 224f8829a4aSRandall Stewart #ifdef SCTP_LOCK_LOGGING 225f8829a4aSRandall Stewart #define SCTP_ASOC_CREATE_LOCK(_inp) \ 226f8829a4aSRandall Stewart do { \ 227f8829a4aSRandall Stewart sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \ 228f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_create_mtx); \ 229f8829a4aSRandall Stewart } while (0) 230f8829a4aSRandall Stewart #else 231f8829a4aSRandall Stewart 232f8829a4aSRandall Stewart #define SCTP_ASOC_CREATE_LOCK(_inp) \ 233f8829a4aSRandall Stewart do { \ 234f8829a4aSRandall Stewart mtx_lock(&(_inp)->inp_create_mtx); \ 235f8829a4aSRandall Stewart } while (0) 236f8829a4aSRandall Stewart #endif 237f8829a4aSRandall Stewart 238f8829a4aSRandall Stewart #define SCTP_INP_RUNLOCK(_inp) mtx_unlock(&(_inp)->inp_mtx) 239f8829a4aSRandall Stewart #define SCTP_INP_WUNLOCK(_inp) mtx_unlock(&(_inp)->inp_mtx) 240f8829a4aSRandall Stewart #define SCTP_ASOC_CREATE_UNLOCK(_inp) mtx_unlock(&(_inp)->inp_create_mtx) 241f8829a4aSRandall Stewart 242f8829a4aSRandall Stewart /* 243f8829a4aSRandall Stewart * For the majority of things (once we have found the association) we will 244f8829a4aSRandall Stewart * lock the actual association mutex. This will protect all the assoiciation 245f8829a4aSRandall Stewart * level queues and streams and such. We will need to lock the socket layer 246f8829a4aSRandall Stewart * when we stuff data up into the receiving sb_mb. I.e. we will need to do an 247f8829a4aSRandall Stewart * extra SOCKBUF_LOCK(&so->so_rcv) even though the association is locked. 248f8829a4aSRandall Stewart */ 249f8829a4aSRandall Stewart 250f8829a4aSRandall Stewart #define SCTP_TCB_LOCK_INIT(_tcb) \ 251f8829a4aSRandall Stewart mtx_init(&(_tcb)->tcb_mtx, "sctp-tcb", "tcb", MTX_DEF | MTX_DUPOK) 252f8829a4aSRandall Stewart 253f8829a4aSRandall Stewart #define SCTP_TCB_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_mtx) 254f8829a4aSRandall Stewart 255f8829a4aSRandall Stewart #ifdef SCTP_LOCK_LOGGING 256f8829a4aSRandall Stewart #define SCTP_TCB_LOCK(_tcb) do { \ 257f8829a4aSRandall Stewart sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \ 258f8829a4aSRandall Stewart mtx_lock(&(_tcb)->tcb_mtx); \ 259f8829a4aSRandall Stewart } while (0) 260f8829a4aSRandall Stewart 261f8829a4aSRandall Stewart #else 262f8829a4aSRandall Stewart #define SCTP_TCB_LOCK(_tcb) do { \ 263f8829a4aSRandall Stewart mtx_lock(&(_tcb)->tcb_mtx); \ 264f8829a4aSRandall Stewart } while (0) 265f8829a4aSRandall Stewart 266f8829a4aSRandall Stewart #endif 267f8829a4aSRandall Stewart 268f8829a4aSRandall Stewart 269f8829a4aSRandall Stewart #define SCTP_TCB_TRYLOCK(_tcb) mtx_trylock(&(_tcb)->tcb_mtx) 270f8829a4aSRandall Stewart 271f8829a4aSRandall Stewart #define SCTP_TCB_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_mtx) 272f8829a4aSRandall Stewart 273f8829a4aSRandall Stewart #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) do { \ 274f8829a4aSRandall Stewart if (mtx_owned(&(_tcb)->tcb_mtx)) \ 275f8829a4aSRandall Stewart mtx_unlock(&(_tcb)->tcb_mtx); \ 276f8829a4aSRandall Stewart } while (0) 277f8829a4aSRandall Stewart 278f8829a4aSRandall Stewart 279f8829a4aSRandall Stewart 280f8829a4aSRandall Stewart #ifdef INVARIANTS 281f8829a4aSRandall Stewart #define SCTP_TCB_LOCK_ASSERT(_tcb) do { \ 282f8829a4aSRandall Stewart if (mtx_owned(&(_tcb)->tcb_mtx) == 0) \ 283f8829a4aSRandall Stewart panic("Don't own TCB lock"); \ 284f8829a4aSRandall Stewart } while (0) 285f8829a4aSRandall Stewart #else 286f8829a4aSRandall Stewart #define SCTP_TCB_LOCK_ASSERT(_tcb) 287f8829a4aSRandall Stewart #endif 288f8829a4aSRandall Stewart 289f8829a4aSRandall Stewart #define SCTP_ITERATOR_LOCK_INIT() \ 290f8829a4aSRandall Stewart mtx_init(&sctppcbinfo.it_mtx, "sctp-it", "iterator", MTX_DEF) 291f8829a4aSRandall Stewart 292f8829a4aSRandall Stewart #ifdef INVARIANTS 293f8829a4aSRandall Stewart #define SCTP_ITERATOR_LOCK() \ 294f8829a4aSRandall Stewart do { \ 295f8829a4aSRandall Stewart if (mtx_owned(&sctppcbinfo.it_mtx)) \ 296f8829a4aSRandall Stewart panic("Iterator Lock"); \ 297f8829a4aSRandall Stewart mtx_lock(&sctppcbinfo.it_mtx); \ 298f8829a4aSRandall Stewart } while (0) 299f8829a4aSRandall Stewart #else 300f8829a4aSRandall Stewart #define SCTP_ITERATOR_LOCK() \ 301f8829a4aSRandall Stewart do { \ 302f8829a4aSRandall Stewart mtx_lock(&sctppcbinfo.it_mtx); \ 303f8829a4aSRandall Stewart } while (0) 304f8829a4aSRandall Stewart 305f8829a4aSRandall Stewart #endif 306f8829a4aSRandall Stewart 307f8829a4aSRandall Stewart #define SCTP_ITERATOR_UNLOCK() mtx_unlock(&sctppcbinfo.it_mtx) 308f8829a4aSRandall Stewart #define SCTP_ITERATOR_LOCK_DESTROY() mtx_destroy(&sctppcbinfo.it_mtx) 309f8829a4aSRandall Stewart 310f8829a4aSRandall Stewart 311f8829a4aSRandall Stewart #define SCTP_INCR_EP_COUNT() \ 312f8829a4aSRandall Stewart do { \ 313f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_ep, 1); \ 314f8829a4aSRandall Stewart } while (0) 315f8829a4aSRandall Stewart 316f8829a4aSRandall Stewart #define SCTP_DECR_EP_COUNT() \ 317f8829a4aSRandall Stewart do { \ 318f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_ep,-1); \ 319f8829a4aSRandall Stewart } while (0) 320f8829a4aSRandall Stewart 321f8829a4aSRandall Stewart #define SCTP_INCR_ASOC_COUNT() \ 322f8829a4aSRandall Stewart do { \ 323f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_asoc, 1); \ 324f8829a4aSRandall Stewart } while (0) 325f8829a4aSRandall Stewart 326f8829a4aSRandall Stewart #define SCTP_DECR_ASOC_COUNT() \ 327f8829a4aSRandall Stewart do { \ 328f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_asoc, -1); \ 329f8829a4aSRandall Stewart } while (0) 330f8829a4aSRandall Stewart 331f8829a4aSRandall Stewart #define SCTP_INCR_LADDR_COUNT() \ 332f8829a4aSRandall Stewart do { \ 333f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_laddr, 1); \ 334f8829a4aSRandall Stewart } while (0) 335f8829a4aSRandall Stewart 336f8829a4aSRandall Stewart #define SCTP_DECR_LADDR_COUNT() \ 337f8829a4aSRandall Stewart do { \ 338f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_laddr, -1); \ 339f8829a4aSRandall Stewart } while (0) 340f8829a4aSRandall Stewart 341f8829a4aSRandall Stewart #define SCTP_INCR_RADDR_COUNT() \ 342f8829a4aSRandall Stewart do { \ 343f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_raddr,1); \ 344f8829a4aSRandall Stewart } while (0) 345f8829a4aSRandall Stewart 346f8829a4aSRandall Stewart #define SCTP_DECR_RADDR_COUNT() \ 347f8829a4aSRandall Stewart do { \ 348f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_raddr,-1); \ 349f8829a4aSRandall Stewart } while (0) 350f8829a4aSRandall Stewart 351f8829a4aSRandall Stewart #define SCTP_INCR_CHK_COUNT() \ 352f8829a4aSRandall Stewart do { \ 353f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_chunk, 1); \ 354f8829a4aSRandall Stewart } while (0) 355f8829a4aSRandall Stewart 356f8829a4aSRandall Stewart #define SCTP_DECR_CHK_COUNT() \ 357f8829a4aSRandall Stewart do { \ 358f8829a4aSRandall Stewart if(sctppcbinfo.ipi_count_chunk == 0) \ 359f8829a4aSRandall Stewart panic("chunk count to 0?"); \ 360f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_chunk,-1); \ 361f8829a4aSRandall Stewart } while (0) 362f8829a4aSRandall Stewart 363f8829a4aSRandall Stewart #define SCTP_INCR_READQ_COUNT() \ 364f8829a4aSRandall Stewart do { \ 365f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_readq,1); \ 366f8829a4aSRandall Stewart } while (0) 367f8829a4aSRandall Stewart 368f8829a4aSRandall Stewart #define SCTP_DECR_READQ_COUNT() \ 369f8829a4aSRandall Stewart do { \ 370f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_readq, -1); \ 371f8829a4aSRandall Stewart } while (0) 372f8829a4aSRandall Stewart 373f8829a4aSRandall Stewart #define SCTP_INCR_STRMOQ_COUNT() \ 374f8829a4aSRandall Stewart do { \ 375f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_strmoq, 1); \ 376f8829a4aSRandall Stewart } while (0) 377f8829a4aSRandall Stewart 378f8829a4aSRandall Stewart #define SCTP_DECR_STRMOQ_COUNT() \ 379f8829a4aSRandall Stewart do { \ 380f8829a4aSRandall Stewart atomic_add_int(&sctppcbinfo.ipi_count_strmoq,-1); \ 381f8829a4aSRandall Stewart } while (0) 382f8829a4aSRandall Stewart 383f8829a4aSRandall Stewart 384f8829a4aSRandall Stewart 385f8829a4aSRandall Stewart 386f8829a4aSRandall Stewart 387f8829a4aSRandall Stewart #endif 388