osif_vdev_sync.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (c) 2018-2019, 2021 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 - vdev synchronization context
  25. * @net_dev: the net_device used as a lookup key
  26. * @dsc_vdev: the dsc_vdev used for synchronization
  27. * @in_use: indicates if the context is being used
  28. */
  29. struct osif_vdev_sync {
  30. struct net_device *net_dev;
  31. struct dsc_vdev *dsc_vdev;
  32. bool in_use;
  33. };
  34. /**
  35. * osif_vdev_sync_create() - create a vdev synchronization context
  36. * @dev: parent device to the vdev
  37. * @out_vdev_sync: out parameter for the new synchronization context
  38. *
  39. * Return: Errno
  40. */
  41. qdf_must_check int
  42. osif_vdev_sync_create(struct device *dev,
  43. struct osif_vdev_sync **out_vdev_sync);
  44. /**
  45. * osif_vdev_sync_create_and_trans() - create a vdev synchronization context
  46. * @dev: parent device to the vdev
  47. * @out_vdev_sync: out parameter for the new synchronization context
  48. *
  49. * For protecting the net_device creation process.
  50. *
  51. * Return: Errno
  52. */
  53. #define osif_vdev_sync_create_and_trans(dev, out_vdev_sync) \
  54. __osif_vdev_sync_create_and_trans(dev, out_vdev_sync, __func__)
  55. qdf_must_check int
  56. __osif_vdev_sync_create_and_trans(struct device *dev,
  57. struct osif_vdev_sync **out_vdev_sync,
  58. const char *desc);
  59. /**
  60. * osif_vdev_sync_destroy() - destroy a vdev synchronization context
  61. * @vdev_sync: the context to destroy
  62. *
  63. * Return: none
  64. */
  65. void osif_vdev_sync_destroy(struct osif_vdev_sync *vdev_sync);
  66. /**
  67. * osif_vdev_sync_register() - register a vdev for operations/transitions
  68. * @net_dev: the net_device to use as the operation/transition lookup key
  69. * @vdev_sync: the vdev synchronization context to register
  70. *
  71. * Return: none
  72. */
  73. void osif_vdev_sync_register(struct net_device *net_dev,
  74. struct osif_vdev_sync *vdev_sync);
  75. /**
  76. * osif_vdev_sync_unregister() - unregister a vdev for operations/transitions
  77. * @net_dev: the net_device originally used to register the vdev_sync context
  78. *
  79. * Return: the vdev synchronization context that was registered for @net_dev
  80. */
  81. struct osif_vdev_sync *osif_vdev_sync_unregister(struct net_device *net_dev);
  82. /**
  83. * osif_vdev_sync_trans_start() - attempt to start a transition on @net_dev
  84. * @net_dev: the net_device to transition
  85. * @out_vdev_sync: out parameter for the synchronization context registered with
  86. * @net_dev, populated on success
  87. *
  88. * Return: Errno
  89. */
  90. #define osif_vdev_sync_trans_start(net_dev, out_vdev_sync) \
  91. __osif_vdev_sync_trans_start(net_dev, out_vdev_sync, __func__)
  92. qdf_must_check int
  93. __osif_vdev_sync_trans_start(struct net_device *net_dev,
  94. struct osif_vdev_sync **out_vdev_sync,
  95. const char *desc);
  96. /**
  97. * osif_vdev_sync_trans_start_wait() - attempt to start a transition on
  98. * @net_dev, blocking if a conflicting transition is in flight
  99. * @net_dev: the net_device to transition
  100. * @out_vdev_sync: out parameter for the synchronization context registered with
  101. * @net_dev, populated on success
  102. *
  103. * Return: Errno
  104. */
  105. #define osif_vdev_sync_trans_start_wait(net_dev, out_vdev_sync) \
  106. __osif_vdev_sync_trans_start_wait(net_dev, out_vdev_sync, __func__)
  107. qdf_must_check int
  108. __osif_vdev_sync_trans_start_wait(struct net_device *net_dev,
  109. struct osif_vdev_sync **out_vdev_sync,
  110. const char *desc);
  111. /**
  112. * osif_vdev_sync_trans_stop() - stop a transition associated with @vdev_sync
  113. * @vdev_sync: the synchonization context tracking the transition
  114. *
  115. * Return: none
  116. */
  117. void osif_vdev_sync_trans_stop(struct osif_vdev_sync *vdev_sync);
  118. /**
  119. * osif_vdev_sync_assert_trans_protected() - assert that @net_dev is currently
  120. * protected by a transition
  121. * @net_dev: the net_device to check
  122. *
  123. * Return: none
  124. */
  125. void osif_vdev_sync_assert_trans_protected(struct net_device *net_dev);
  126. /**
  127. * osif_vdev_sync_op_start() - attempt to start an operation on @net_dev
  128. * @net_dev: the net_device to operate against
  129. * @out_vdev_sync: out parameter for the synchronization context registered with
  130. * @net_dev, populated on success
  131. *
  132. * Return: Errno
  133. */
  134. #define osif_vdev_sync_op_start(net_dev, out_vdev_sync) \
  135. __osif_vdev_sync_op_start(net_dev, out_vdev_sync, __func__)
  136. qdf_must_check int
  137. __osif_vdev_sync_op_start(struct net_device *net_dev,
  138. struct osif_vdev_sync **out_vdev_sync,
  139. const char *func);
  140. /**
  141. * osif_vdev_sync_op_stop() - stop an operation associated with @vdev_sync
  142. * @vdev_sync: the synchonization context tracking the operation
  143. *
  144. * Return: none
  145. */
  146. #define osif_vdev_sync_op_stop(net_dev) \
  147. __osif_vdev_sync_op_stop(net_dev, __func__)
  148. void __osif_vdev_sync_op_stop(struct osif_vdev_sync *vdev_sync,
  149. const char *func);
  150. /**
  151. * osif_vdev_sync_wait_for_ops() - wait until all @vdev_sync operations complete
  152. * @vdev_sync: the synchonization context tracking the operations
  153. *
  154. * Return: None
  155. */
  156. void osif_vdev_sync_wait_for_ops(struct osif_vdev_sync *vdev_sync);
  157. /**
  158. * osif_vdev_get_cached_cmd() - Get north bound cmd cached during SSR
  159. * @vdev_sync: osif vdev sync corresponding to the network interface
  160. *
  161. * This api will be invoked after completion of SSR re-initialization to get
  162. * the last north bound command received during SSR
  163. *
  164. * Return: North bound command ID
  165. */
  166. uint8_t osif_vdev_get_cached_cmd(struct osif_vdev_sync *vdev_sync);
  167. /**
  168. * osif_vdev_cache_command() - Cache north bound command during SSR
  169. * @vdev_sync: osif vdev sync corresponding to the network interface
  170. * @cmd_id: North bound command ID
  171. *
  172. * This api will be invoked when a north bound command is received during SSR
  173. * and it should be handled after SSR re-initialization.
  174. *
  175. * Return: None
  176. */
  177. void osif_vdev_cache_command(struct osif_vdev_sync *vdev_sync, uint8_t cmd_id);
  178. /**
  179. * osif_get_vdev_sync_arr() - Get vdev sync array base pointer
  180. *
  181. * Return: Base pointer to the vdev sync array
  182. */
  183. struct osif_vdev_sync *osif_get_vdev_sync_arr(void);
  184. #endif /* __OSIF_VDEV_SYNC_H */