osif_vdev_sync.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef __OSIF_VDEV_SYNC_H
  19. #define __OSIF_VDEV_SYNC_H
  20. #include "linux/device.h"
  21. #include "linux/netdevice.h"
  22. #include "qdf_types.h"
  23. /**
  24. * struct osif_vdev_sync - opaque synchronization handle for a vdev
  25. */
  26. struct osif_vdev_sync;
  27. /**
  28. * osif_vdev_sync_create() - create a vdev synchronization context
  29. * @dev: parent device to the vdev
  30. * @out_vdev_sync: out parameter for the new synchronization context
  31. *
  32. * Return: Errno
  33. */
  34. qdf_must_check int
  35. osif_vdev_sync_create(struct device *dev,
  36. struct osif_vdev_sync **out_vdev_sync);
  37. /**
  38. * osif_vdev_sync_create_and_trans() - create a vdev synchronization context
  39. * @dev: parent device to the vdev
  40. * @out_vdev_sync: out parameter for the new synchronization context
  41. *
  42. * For protecting the net_device creation process.
  43. *
  44. * Return: Errno
  45. */
  46. #define osif_vdev_sync_create_and_trans(dev, out_vdev_sync) \
  47. __osif_vdev_sync_create_and_trans(dev, out_vdev_sync, __func__)
  48. qdf_must_check int
  49. __osif_vdev_sync_create_and_trans(struct device *dev,
  50. struct osif_vdev_sync **out_vdev_sync,
  51. const char *desc);
  52. /**
  53. * osif_vdev_sync_destroy() - destroy a vdev synchronization context
  54. * @vdev_sync: the context to destroy
  55. *
  56. * Return: none
  57. */
  58. void osif_vdev_sync_destroy(struct osif_vdev_sync *vdev_sync);
  59. /**
  60. * osif_vdev_sync_register() - register a vdev for operations/transitions
  61. * @net_dev: the net_device to use as the operation/transition lookup key
  62. * @vdev_sync: the vdev synchronization context to register
  63. *
  64. * Return: none
  65. */
  66. void osif_vdev_sync_register(struct net_device *net_dev,
  67. struct osif_vdev_sync *vdev_sync);
  68. /**
  69. * osif_vdev_sync_unregister() - unregister a vdev for operations/transitions
  70. * @net_dev: the net_device originally used to register the vdev_sync context
  71. *
  72. * Return: the vdev synchronization context that was registered for @net_dev
  73. */
  74. struct osif_vdev_sync *osif_vdev_sync_unregister(struct net_device *net_dev);
  75. /**
  76. * osif_vdev_sync_trans_start() - attempt to start a transition on @net_dev
  77. * @net_dev: the net_device to transition
  78. * @out_vdev_sync: out parameter for the synchronization context registered with
  79. * @net_dev, populated on success
  80. *
  81. * Return: Errno
  82. */
  83. #define osif_vdev_sync_trans_start(net_dev, out_vdev_sync) \
  84. __osif_vdev_sync_trans_start(net_dev, out_vdev_sync, __func__)
  85. qdf_must_check int
  86. __osif_vdev_sync_trans_start(struct net_device *net_dev,
  87. struct osif_vdev_sync **out_vdev_sync,
  88. const char *desc);
  89. /**
  90. * osif_vdev_sync_trans_start_wait() - attempt to start a transition on
  91. * @net_dev, blocking if a conflicting transition is in flight
  92. * @net_dev: the net_device to transition
  93. * @out_vdev_sync: out parameter for the synchronization context registered with
  94. * @net_dev, populated on success
  95. *
  96. * Return: Errno
  97. */
  98. #define osif_vdev_sync_trans_start_wait(net_dev, out_vdev_sync) \
  99. __osif_vdev_sync_trans_start_wait(net_dev, out_vdev_sync, __func__)
  100. qdf_must_check int
  101. __osif_vdev_sync_trans_start_wait(struct net_device *net_dev,
  102. struct osif_vdev_sync **out_vdev_sync,
  103. const char *desc);
  104. /**
  105. * osif_vdev_sync_trans_stop() - stop a transition associated with @vdev_sync
  106. * @vdev_sync: the synchonization context tracking the transition
  107. *
  108. * Return: none
  109. */
  110. void osif_vdev_sync_trans_stop(struct osif_vdev_sync *vdev_sync);
  111. /**
  112. * osif_vdev_sync_assert_trans_protected() - assert that @net_dev is currently
  113. * protected by a transition
  114. * @net_dev: the net_device to check
  115. *
  116. * Return: none
  117. */
  118. void osif_vdev_sync_assert_trans_protected(struct net_device *net_dev);
  119. /**
  120. * osif_vdev_sync_op_start() - attempt to start an operation on @net_dev
  121. * @net_dev: the net_device to operate against
  122. * @out_vdev_sync: out parameter for the synchronization context registered with
  123. * @net_dev, populated on success
  124. *
  125. * Return: Errno
  126. */
  127. #define osif_vdev_sync_op_start(net_dev, out_vdev_sync) \
  128. __osif_vdev_sync_op_start(net_dev, out_vdev_sync, __func__)
  129. qdf_must_check int
  130. __osif_vdev_sync_op_start(struct net_device *net_dev,
  131. struct osif_vdev_sync **out_vdev_sync,
  132. const char *func);
  133. /**
  134. * osif_vdev_sync_op_stop() - stop an operation associated with @vdev_sync
  135. * @vdev_sync: the synchonization context tracking the operation
  136. *
  137. * Return: none
  138. */
  139. #define osif_vdev_sync_op_stop(net_dev) \
  140. __osif_vdev_sync_op_stop(net_dev, __func__)
  141. void __osif_vdev_sync_op_stop(struct osif_vdev_sync *vdev_sync,
  142. const char *func);
  143. /**
  144. * osif_vdev_sync_wait_for_ops() - wait until all @vdev_sync operations complete
  145. * @vdev_sync: the synchonization context tracking the operations
  146. *
  147. * Return: None
  148. */
  149. void osif_vdev_sync_wait_for_ops(struct osif_vdev_sync *vdev_sync);
  150. #endif /* __OSIF_VDEV_SYNC_H */