osif_vdev_sync.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef __OSIF_VDEV_SYNC_H
  20. #define __OSIF_VDEV_SYNC_H
  21. #include "linux/device.h"
  22. #include "linux/netdevice.h"
  23. #include "qdf_types.h"
  24. /**
  25. * struct osif_vdev_sync - vdev synchronization context
  26. * @net_dev: the net_device used as a lookup key
  27. * @dsc_vdev: the dsc_vdev used for synchronization
  28. * @in_use: indicates if the context is being used
  29. */
  30. struct osif_vdev_sync {
  31. struct net_device *net_dev;
  32. struct dsc_vdev *dsc_vdev;
  33. bool in_use;
  34. };
  35. /**
  36. * osif_vdev_sync_create() - create a vdev synchronization context
  37. * @dev: parent device to the vdev
  38. * @out_vdev_sync: out parameter for the new synchronization context
  39. *
  40. * Return: Errno
  41. */
  42. qdf_must_check int
  43. osif_vdev_sync_create(struct device *dev,
  44. struct osif_vdev_sync **out_vdev_sync);
  45. /**
  46. * osif_vdev_sync_create_and_trans() - create a vdev synchronization context
  47. * @dev: parent device to the vdev
  48. * @out_vdev_sync: out parameter for the new synchronization context
  49. *
  50. * For protecting the net_device creation process.
  51. *
  52. * Return: Errno
  53. */
  54. #define osif_vdev_sync_create_and_trans(dev, out_vdev_sync) \
  55. __osif_vdev_sync_create_and_trans(dev, out_vdev_sync, __func__)
  56. qdf_must_check int
  57. __osif_vdev_sync_create_and_trans(struct device *dev,
  58. struct osif_vdev_sync **out_vdev_sync,
  59. const char *desc);
  60. /**
  61. * osif_vdev_sync_destroy() - destroy a vdev synchronization context
  62. * @vdev_sync: the context to destroy
  63. *
  64. * Return: none
  65. */
  66. void osif_vdev_sync_destroy(struct osif_vdev_sync *vdev_sync);
  67. /**
  68. * osif_vdev_sync_register() - register a vdev for operations/transitions
  69. * @net_dev: the net_device to use as the operation/transition lookup key
  70. * @vdev_sync: the vdev synchronization context to register
  71. *
  72. * Return: none
  73. */
  74. void osif_vdev_sync_register(struct net_device *net_dev,
  75. struct osif_vdev_sync *vdev_sync);
  76. /**
  77. * osif_vdev_sync_unregister() - unregister a vdev for operations/transitions
  78. * @net_dev: the net_device originally used to register the vdev_sync context
  79. *
  80. * Return: the vdev synchronization context that was registered for @net_dev
  81. */
  82. struct osif_vdev_sync *osif_vdev_sync_unregister(struct net_device *net_dev);
  83. /**
  84. * osif_vdev_sync_trans_start() - attempt to start a transition on @net_dev
  85. * @net_dev: the net_device to transition
  86. * @out_vdev_sync: out parameter for the synchronization context registered with
  87. * @net_dev, populated on success
  88. *
  89. * Return: Errno
  90. */
  91. #define osif_vdev_sync_trans_start(net_dev, out_vdev_sync) \
  92. __osif_vdev_sync_trans_start(net_dev, out_vdev_sync, __func__)
  93. qdf_must_check int
  94. __osif_vdev_sync_trans_start(struct net_device *net_dev,
  95. struct osif_vdev_sync **out_vdev_sync,
  96. const char *desc);
  97. /**
  98. * osif_vdev_sync_trans_start_wait() - attempt to start a transition on
  99. * @net_dev, blocking if a conflicting transition is in flight
  100. * @net_dev: the net_device to transition
  101. * @out_vdev_sync: out parameter for the synchronization context registered with
  102. * @net_dev, populated on success
  103. *
  104. * Return: Errno
  105. */
  106. #define osif_vdev_sync_trans_start_wait(net_dev, out_vdev_sync) \
  107. __osif_vdev_sync_trans_start_wait(net_dev, out_vdev_sync, __func__)
  108. qdf_must_check int
  109. __osif_vdev_sync_trans_start_wait(struct net_device *net_dev,
  110. struct osif_vdev_sync **out_vdev_sync,
  111. const char *desc);
  112. /**
  113. * osif_vdev_sync_trans_stop() - stop a transition associated with @vdev_sync
  114. * @vdev_sync: the synchronization context tracking the transition
  115. *
  116. * Return: none
  117. */
  118. void osif_vdev_sync_trans_stop(struct osif_vdev_sync *vdev_sync);
  119. /**
  120. * osif_vdev_sync_assert_trans_protected() - assert that @net_dev is currently
  121. * protected by a transition
  122. * @net_dev: the net_device to check
  123. *
  124. * Return: none
  125. */
  126. void osif_vdev_sync_assert_trans_protected(struct net_device *net_dev);
  127. /**
  128. * osif_vdev_sync_op_start() - attempt to start an operation on @net_dev
  129. * @net_dev: the net_device to operate against
  130. * @out_vdev_sync: out parameter for the synchronization context registered with
  131. * @net_dev, populated on success
  132. *
  133. * Return: Errno
  134. */
  135. #define osif_vdev_sync_op_start(net_dev, out_vdev_sync) \
  136. __osif_vdev_sync_op_start(net_dev, out_vdev_sync, __func__)
  137. qdf_must_check int
  138. __osif_vdev_sync_op_start(struct net_device *net_dev,
  139. struct osif_vdev_sync **out_vdev_sync,
  140. const char *func);
  141. /**
  142. * osif_vdev_sync_op_stop() - stop an operation associated with @vdev_sync
  143. * @vdev_sync: the synchronization context tracking the operation
  144. *
  145. * Return: none
  146. */
  147. #define osif_vdev_sync_op_stop(vdev_sync) \
  148. __osif_vdev_sync_op_stop(vdev_sync, __func__)
  149. void __osif_vdev_sync_op_stop(struct osif_vdev_sync *vdev_sync,
  150. const char *func);
  151. /**
  152. * osif_vdev_sync_wait_for_ops() - wait until all @vdev_sync operations complete
  153. * @vdev_sync: the synchronization context tracking the operations
  154. *
  155. * Return: None
  156. */
  157. void osif_vdev_sync_wait_for_ops(struct osif_vdev_sync *vdev_sync);
  158. /**
  159. * osif_vdev_get_cached_cmd() - Get north bound cmd cached during SSR
  160. * @vdev_sync: osif vdev sync corresponding to the network interface
  161. *
  162. * This api will be invoked after completion of SSR re-initialization to get
  163. * the last north bound command received during SSR
  164. *
  165. * Return: North bound command ID
  166. */
  167. uint8_t osif_vdev_get_cached_cmd(struct osif_vdev_sync *vdev_sync);
  168. /**
  169. * osif_vdev_cache_command() - Cache north bound command during SSR
  170. * @vdev_sync: osif vdev sync corresponding to the network interface
  171. * @cmd_id: North bound command ID
  172. *
  173. * This api will be invoked when a north bound command is received during SSR
  174. * and it should be handled after SSR re-initialization.
  175. *
  176. * Return: None
  177. */
  178. void osif_vdev_cache_command(struct osif_vdev_sync *vdev_sync, uint8_t cmd_id);
  179. /**
  180. * osif_get_vdev_sync_arr() - Get vdev sync array base pointer
  181. *
  182. * Return: Base pointer to the vdev sync array
  183. */
  184. struct osif_vdev_sync *osif_get_vdev_sync_arr(void);
  185. #endif /* __OSIF_VDEV_SYNC_H */