qdf_defer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (c) 2014, 2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * DOC: cdf_defer.h
  28. * This file abstracts deferred execution contexts.
  29. */
  30. #ifndef __CDF_DEFER_H
  31. #define __CDF_DEFER_H
  32. #include <cdf_types.h>
  33. #include <i_cdf_defer.h>
  34. /**
  35. * This implements work queues (worker threads, kernel threads etc.).
  36. * Note that there is no cancel on a scheduled work. You cannot free a work
  37. * item if its queued. You cannot know if a work item is queued or not unless
  38. * its running, whence you know its not queued.
  39. *
  40. * so if, say, a module is asked to unload itself, how exactly will it make
  41. * sure that the work's not queued, for OS'es that dont provide such a
  42. * mechanism??
  43. */
  44. /* cdf_work_t - representation of a work queue */
  45. typedef __cdf_work_t cdf_work_t;
  46. /* cdf_work_t - representation of a bottom half */
  47. typedef __cdf_bh_t cdf_bh_t;
  48. /**
  49. * cdf_create_bh() - this creates the Bottom half deferred handler
  50. * @hdl: OS handle
  51. * @bh: Bottom instance
  52. * @func: Func deferred function to run at bottom half interrupt
  53. * context
  54. * Return: None
  55. */
  56. static inline void
  57. cdf_create_bh(cdf_handle_t hdl, cdf_bh_t *bh, cdf_defer_fn_t func, void *arg)
  58. {
  59. __cdf_init_bh(hdl, bh, func, arg);
  60. }
  61. /**
  62. * cdf_sched_bh() - schedule a bottom half (DPC)
  63. * @hdl: OS handle
  64. * @bh: Bottom instance
  65. *
  66. * Return: None
  67. */
  68. static inline void cdf_sched_bh(cdf_handle_t hdl, cdf_bh_t *bh)
  69. {
  70. __cdf_sched_bh(hdl, bh);
  71. }
  72. /**
  73. * cdf_destroy_bh() - destroy a bottom half (DPC)
  74. * @hdl: OS handle
  75. * @bh: Bottom instance
  76. *
  77. * Return: None
  78. */
  79. static inline void cdf_destroy_bh(cdf_handle_t hdl, cdf_bh_t *bh)
  80. {
  81. __cdf_disable_bh(hdl, bh);
  82. }
  83. /*********************Non-Interrupt Context deferred Execution***************/
  84. /**
  85. * cdf_create_work() - create a work/task queue, This runs in non-interrupt
  86. * context, so can be preempted by H/W & S/W intr
  87. * @work: Work instance
  88. * @func: Deferred function to run at bottom half non-interrupt
  89. * context
  90. * @arg: Argument for the deferred function
  91. *
  92. * Return: None
  93. */
  94. static inline void
  95. cdf_create_work(cdf_work_t *work,
  96. cdf_defer_fn_t func, void *arg)
  97. {
  98. __cdf_init_work(work, func, arg);
  99. }
  100. /**
  101. * cdf_sched_work() - schedule a deferred task on non-interrupt context
  102. * @work: Work instance
  103. *
  104. * Return: None
  105. */
  106. static inline void cdf_schedule_work(cdf_work_t *work)
  107. {
  108. __cdf_schedule_work(work);
  109. }
  110. #endif /*__CDF_DEFER_H*/