qdf_streamfs.h 5.6 KB

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