Deleted Added
full compact
sctp_lock_bsd.h (182367) sctp_lock_bsd.h (208160)
1#ifndef __sctp_lock_bsd_h__
2#define __sctp_lock_bsd_h__
3/*-
4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

--- 55 unchanged lines hidden (view full) ---

64
65/*
66 * When working with the global SCTP lists we lock and unlock the INP_INFO
67 * lock. So when we go to lookup an association we will want to do a
68 * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to
69 * the SCTP_BASE_INFO() list's we will do a SCTP_INP_INFO_WLOCK().
70 */
71#include <sys/cdefs.h>
1#ifndef __sctp_lock_bsd_h__
2#define __sctp_lock_bsd_h__
3/*-
4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

--- 55 unchanged lines hidden (view full) ---

64
65/*
66 * When working with the global SCTP lists we lock and unlock the INP_INFO
67 * lock. So when we go to lookup an association we will want to do a
68 * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to
69 * the SCTP_BASE_INFO() list's we will do a SCTP_INP_INFO_WLOCK().
70 */
71#include <sys/cdefs.h>
72__FBSDID("$FreeBSD: head/sys/netinet/sctp_lock_bsd.h 182367 2008-08-28 09:44:07Z rrs $");
72__FBSDID("$FreeBSD: head/sys/netinet/sctp_lock_bsd.h 208160 2010-05-16 17:03:56Z rrs $");
73
74
75extern struct sctp_foo_stuff sctp_logoff[];
76extern int sctp_logoff_stuff;
77
78#define SCTP_IPI_COUNT_INIT()
79
80#define SCTP_STATLOG_INIT_LOCK()

--- 21 unchanged lines hidden (view full) ---

102 rw_wlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
103} while (0)
104
105
106#define SCTP_INP_INFO_RUNLOCK() rw_runlock(&SCTP_BASE_INFO(ipi_ep_mtx))
107#define SCTP_INP_INFO_WUNLOCK() rw_wunlock(&SCTP_BASE_INFO(ipi_ep_mtx))
108
109
73
74
75extern struct sctp_foo_stuff sctp_logoff[];
76extern int sctp_logoff_stuff;
77
78#define SCTP_IPI_COUNT_INIT()
79
80#define SCTP_STATLOG_INIT_LOCK()

--- 21 unchanged lines hidden (view full) ---

102 rw_wlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
103} while (0)
104
105
106#define SCTP_INP_INFO_RUNLOCK() rw_runlock(&SCTP_BASE_INFO(ipi_ep_mtx))
107#define SCTP_INP_INFO_WUNLOCK() rw_wunlock(&SCTP_BASE_INFO(ipi_ep_mtx))
108
109
110#define SCTP_IPI_ADDR_INIT() \
110#define SCTP_IPI_ADDR_INIT() \
111 rw_init(&SCTP_BASE_INFO(ipi_addr_mtx), "sctp-addr")
111 rw_init(&SCTP_BASE_INFO(ipi_addr_mtx), "sctp-addr")
112
113#define SCTP_IPI_ADDR_DESTROY() do { \
114 if(rw_wowned(&SCTP_BASE_INFO(ipi_addr_mtx))) { \
115 rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
116 } \
117 rw_destroy(&SCTP_BASE_INFO(ipi_addr_mtx)); \
118 } while (0)
112#define SCTP_IPI_ADDR_DESTROY() do { \
113 if(rw_wowned(&SCTP_BASE_INFO(ipi_addr_mtx))) { \
114 rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
115 } \
116 rw_destroy(&SCTP_BASE_INFO(ipi_addr_mtx)); \
117 } while (0)
119
120
121
122#define SCTP_IPI_ADDR_RLOCK() do { \
123 rw_rlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
124} while (0)
118#define SCTP_IPI_ADDR_RLOCK() do { \
119 rw_rlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
120} while (0)
125
126#define SCTP_IPI_ADDR_WLOCK() do { \
127 rw_wlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
128} while (0)
129
121#define SCTP_IPI_ADDR_WLOCK() do { \
122 rw_wlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
123} while (0)
124
130
131#define SCTP_IPI_ADDR_RUNLOCK() rw_runlock(&SCTP_BASE_INFO(ipi_addr_mtx))
132#define SCTP_IPI_ADDR_WUNLOCK() rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx))
133
134
135#define SCTP_IPI_ITERATOR_WQ_INIT() \
125#define SCTP_IPI_ADDR_RUNLOCK() rw_runlock(&SCTP_BASE_INFO(ipi_addr_mtx))
126#define SCTP_IPI_ADDR_WUNLOCK() rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx))
127
128
129#define SCTP_IPI_ITERATOR_WQ_INIT() \
136 mtx_init(&SCTP_BASE_INFO(ipi_iterator_wq_mtx), "sctp-it-wq", "sctp_it_wq", MTX_DEF)
130 mtx_init(&sctp_it_ctl.ipi_iterator_wq_mtx, "sctp-it-wq", "sctp_it_wq", MTX_DEF)
137
138#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
131
132#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
139 mtx_destroy(&SCTP_BASE_INFO(ipi_iterator_wq_mtx))
133 mtx_destroy(&sctp_it_ctl.ipi_iterator_wq_mtx)
140
141#define SCTP_IPI_ITERATOR_WQ_LOCK() do { \
134
135#define SCTP_IPI_ITERATOR_WQ_LOCK() do { \
142 mtx_lock(&SCTP_BASE_INFO(ipi_iterator_wq_mtx)); \
136 mtx_lock(&sctp_it_ctl.ipi_iterator_wq_mtx); \
143} while (0)
144
137} while (0)
138
145#define SCTP_IPI_ITERATOR_WQ_UNLOCK() mtx_unlock(&SCTP_BASE_INFO(ipi_iterator_wq_mtx))
139#define SCTP_IPI_ITERATOR_WQ_UNLOCK() mtx_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx)
146
147
148#define SCTP_IP_PKTLOG_INIT() \
149 mtx_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), "sctp-pktlog", "packetlog", MTX_DEF)
150
151
152#define SCTP_IP_PKTLOG_LOCK() do { \
153 mtx_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \

--- 141 unchanged lines hidden (view full) ---

295 if (mtx_owned(&(_tcb)->tcb_mtx) == 0) \
296 panic("Don't own TCB lock"); \
297 } while (0)
298#else
299#define SCTP_TCB_LOCK_ASSERT(_tcb)
300#endif
301
302#define SCTP_ITERATOR_LOCK_INIT() \
140
141
142#define SCTP_IP_PKTLOG_INIT() \
143 mtx_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), "sctp-pktlog", "packetlog", MTX_DEF)
144
145
146#define SCTP_IP_PKTLOG_LOCK() do { \
147 mtx_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \

--- 141 unchanged lines hidden (view full) ---

289 if (mtx_owned(&(_tcb)->tcb_mtx) == 0) \
290 panic("Don't own TCB lock"); \
291 } while (0)
292#else
293#define SCTP_TCB_LOCK_ASSERT(_tcb)
294#endif
295
296#define SCTP_ITERATOR_LOCK_INIT() \
303 mtx_init(&SCTP_BASE_INFO(it_mtx), "sctp-it", "iterator", MTX_DEF)
297 mtx_init(&sctp_it_ctl.it_mtx, "sctp-it", "iterator", MTX_DEF)
304
305#ifdef INVARIANTS
306#define SCTP_ITERATOR_LOCK() \
307 do { \
298
299#ifdef INVARIANTS
300#define SCTP_ITERATOR_LOCK() \
301 do { \
308 if (mtx_owned(&SCTP_BASE_INFO(it_mtx))) \
302 if (mtx_owned(&sctp_it_ctl.it_mtx)) \
309 panic("Iterator Lock"); \
303 panic("Iterator Lock"); \
310 mtx_lock(&SCTP_BASE_INFO(it_mtx)); \
304 mtx_lock(&sctp_it_ctl.it_mtx); \
311 } while (0)
312#else
313#define SCTP_ITERATOR_LOCK() \
314 do { \
305 } while (0)
306#else
307#define SCTP_ITERATOR_LOCK() \
308 do { \
315 mtx_lock(&SCTP_BASE_INFO(it_mtx)); \
309 mtx_lock(&sctp_it_ctl.it_mtx); \
316 } while (0)
317
318#endif
319
310 } while (0)
311
312#endif
313
320#define SCTP_ITERATOR_UNLOCK() mtx_unlock(&SCTP_BASE_INFO(it_mtx))
321#define SCTP_ITERATOR_LOCK_DESTROY() mtx_destroy(&SCTP_BASE_INFO(it_mtx))
314#define SCTP_ITERATOR_UNLOCK() mtx_unlock(&sctp_it_ctl.it_mtx)
315#define SCTP_ITERATOR_LOCK_DESTROY() mtx_destroy(&sctp_it_ctl.it_mtx)
322
323
316
317
318#define SCTP_WQ_ADDR_INIT() do { \
319 mtx_init(&SCTP_BASE_INFO(wq_addr_mtx), "sctp-addr-wq","sctp_addr_wq",MTX_DEF); \
320 } while (0)
321
322#define SCTP_WQ_ADDR_DESTROY() do { \
323 if(mtx_owned(&SCTP_BASE_INFO(wq_addr_mtx))) { \
324 mtx_unlock(&SCTP_BASE_INFO(wq_addr_mtx)); \
325 } \
326 mtx_destroy(&SCTP_BASE_INFO(wq_addr_mtx)); \
327 } while (0)
328
329#define SCTP_WQ_ADDR_LOCK() do { \
330 mtx_lock(&SCTP_BASE_INFO(wq_addr_mtx)); \
331} while (0)
332#define SCTP_WQ_ADDR_UNLOCK() do { \
333 mtx_unlock(&SCTP_BASE_INFO(wq_addr_mtx)); \
334} while (0)
335
336
337
324#define SCTP_INCR_EP_COUNT() \
325 do { \
326 atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \
327 } while (0)
328
329#define SCTP_DECR_EP_COUNT() \
330 do { \
331 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \

--- 78 unchanged lines hidden ---
338#define SCTP_INCR_EP_COUNT() \
339 do { \
340 atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \
341 } while (0)
342
343#define SCTP_DECR_EP_COUNT() \
344 do { \
345 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \

--- 78 unchanged lines hidden ---