sctp_lock_userspace.h 7.3 KB

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