qdf_streamfs.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright (c) 2018, 2020 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. /**
  19. * DOC: qdf_streamfs.h
  20. * This file provides OS abstraction for stream filesystem APIs.
  21. */
  22. #ifndef _QDF_STREAMFS_H
  23. #define _QDF_STREAMFS_H
  24. #include <i_qdf_streamfs.h>
  25. #include <qdf_types.h>
  26. #include <qdf_debugfs.h>
  27. typedef __qdf_streamfs_chan_t qdf_streamfs_chan_t;
  28. typedef __qdf_streamfs_chan_buf_t qdf_streamfs_chan_buf_t;
  29. #ifdef WLAN_STREAMFS
  30. /**
  31. * qdf_streamfs_create_dir() - wrapper to create a debugfs directory
  32. * @name: name of the new directory
  33. * @parent: parent node. If NULL, defaults to base qdf_debugfs_root
  34. *
  35. * Return: dentry structure pointer in case of success, otherwise NULL.
  36. *
  37. */
  38. static inline qdf_dentry_t qdf_streamfs_create_dir(
  39. const char *name, qdf_dentry_t parent)
  40. {
  41. return qdf_debugfs_create_dir(name, parent);
  42. }
  43. /**
  44. * qdf_streamfs_remove_file() - wrapper to remove streamfs file
  45. * @d: streamfs node
  46. *
  47. */
  48. static inline void qdf_streamfs_remove_file(qdf_dentry_t d)
  49. {
  50. qdf_debugfs_remove_file(d);
  51. }
  52. /**
  53. * qdf_debugfs_remove_dir_recursive() - wrapper to remove directory recursively
  54. * @d: debugfs node
  55. *
  56. * This function will recursively remove a directory in streamfs that was
  57. * previously created with a call to qdf_debugfs_create_file() or it's
  58. * variant functions.
  59. */
  60. static inline void qdf_streamfs_remove_dir_recursive(qdf_dentry_t d)
  61. {
  62. qdf_debugfs_remove_dir_recursive(d);
  63. }
  64. /**
  65. * qdf_streamfs_create_file() - Create streamfs chan buffer file
  66. * @name: base name of file to create
  67. * @mode: filemode
  68. * @parent: dentry of parent directory, NULL for root directory
  69. * @buf: pointer to chan buffer
  70. *
  71. * Returns file dentry pointer if successful, NULL otherwise.
  72. */
  73. qdf_dentry_t qdf_streamfs_create_file(const char *name, uint16_t mode,
  74. qdf_dentry_t parent,
  75. qdf_streamfs_chan_buf_t buf);
  76. /**
  77. * qdf_streamfs_open() - Create streamfs channel for data trasfer
  78. * @base_filename: base name of files to create, %NULL for buffering only
  79. * @parent: dentry of parent directory, %NULL for root directory
  80. * @subbuf_size: size of sub-buffers
  81. * @n_subbufs: number of sub-buffers
  82. * @private_data: user-defined data
  83. *
  84. * Returns channel pointer if successful, %NULL otherwise.
  85. */
  86. qdf_streamfs_chan_t qdf_streamfs_open(const char *base_filename,
  87. qdf_dentry_t parent,
  88. size_t subbuf_size, size_t n_subbufs,
  89. void *private_data);
  90. /**
  91. * qdf_streamfs_close() - Closes all channel buffers and frees the channel.
  92. * @chan: pointer to qdf_streamfs_chan.
  93. *
  94. * Returns NONE
  95. */
  96. void qdf_streamfs_close(qdf_streamfs_chan_t chan);
  97. /**
  98. * qdf_streamfs_flush() - Flushes all channel buffers.
  99. * @chan: pointer to qdf_streamfs_chan.
  100. *
  101. * Returns NONE
  102. */
  103. void qdf_streamfs_flush(qdf_streamfs_chan_t chan);
  104. /**
  105. * qdf_streamfs_reset() - Reset streamfs channel
  106. * @chan: pointer to qdf_streamfs_chan.
  107. *
  108. * This erases data from all channel buffers and restarting the channel
  109. * in its initial state. The buffers are not freed, so any mappings are
  110. * still in effect.
  111. *
  112. * Returns NONE
  113. */
  114. void qdf_streamfs_reset(qdf_streamfs_chan_t chan);
  115. /**
  116. * qdf_streamfs_subbufs_consumed() - update the buffer's sub-buffers-consumed
  117. * count
  118. * @chan: pointer to qdf_streamfs_chan.
  119. * @cpu: the cpu associated with the channel buffer to update
  120. * @subbufs_consumed: number of sub-buffers to add to current buf's count
  121. *
  122. * Returns NONE
  123. */
  124. void qdf_streamfs_subbufs_consumed(qdf_streamfs_chan_t chan,
  125. unsigned int cpu,
  126. size_t consumed);
  127. /**
  128. * qdf_streamfs_write() - write data into the channel
  129. * @chan: relay channel
  130. * @data: data to be written
  131. * @length: number of bytes to write
  132. *
  133. * Writes data into the current cpu's channel buffer.
  134. */
  135. void qdf_streamfs_write(qdf_streamfs_chan_t chan, const void *data,
  136. size_t length);
  137. #else
  138. static inline qdf_dentry_t qdf_streamfs_create_dir(
  139. const char *name, qdf_dentry_t parent)
  140. {
  141. return NULL;
  142. }
  143. static inline void qdf_streamfs_remove_file(qdf_dentry_t d)
  144. {
  145. }
  146. static inline void qdf_streamfs_remove_dir_recursive(qdf_dentry_t d)
  147. {
  148. }
  149. static inline
  150. qdf_dentry_t qdf_streamfs_create_file(const char *name, uint16_t mode,
  151. qdf_dentry_t parent,
  152. qdf_streamfs_chan_buf_t buf)
  153. {
  154. return NULL;
  155. }
  156. static inline
  157. qdf_streamfs_chan_t qdf_streamfs_open(const char *base_filename,
  158. qdf_dentry_t parent,
  159. size_t subbuf_size, size_t n_subbufs,
  160. void *private_data)
  161. {
  162. return NULL;
  163. }
  164. static inline void qdf_streamfs_close(qdf_streamfs_chan_t chan)
  165. {
  166. }
  167. static inline void qdf_streamfs_flush(qdf_streamfs_chan_t chan)
  168. {
  169. }
  170. static inline void qdf_streamfs_reset(qdf_streamfs_chan_t chan)
  171. {
  172. }
  173. static inline void
  174. qdf_streamfs_subbufs_consumed(qdf_streamfs_chan_t chan,
  175. unsigned int cpu, size_t consumed)
  176. {
  177. }
  178. static inline void
  179. qdf_streamfs_write(qdf_streamfs_chan_t chan, const void *data,
  180. size_t length)
  181. {
  182. }
  183. #endif /* WLAN_STREAMFS */
  184. #endif /* _QDF_STREAMFS_H */