qal_streamfs.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c) 2018 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: qal_streamfs
  20. * stream file system APIs
  21. */
  22. #if !defined(__QAL_STREAMFS_H)
  23. #define _QAL_STREAMFS_H
  24. /* Include Files */
  25. #include <qdf_types.h>
  26. struct qal_streamfs_chan;
  27. struct qal_dentry_t;
  28. struct qal_streamfs_chan_callbacks;
  29. struct qal_streamfs_chan_buf;
  30. /**
  31. * qal_streamfs_create_dir() - Create streamfs directory
  32. * @name: name of directory to create
  33. * @parent: dentry of parent directory, NULL for root directory
  34. *
  35. * Returns directory dentry pointer if successful, NULL otherwise.
  36. */
  37. struct qal_dentry_t *
  38. qal_streamfs_create_dir(const char *name, struct qal_dentry_t *parent);
  39. /**
  40. * qal_streamfs_create_file() - Create streamfs chan buffer file
  41. * @name: base name of file to create
  42. * @mode: filemode
  43. * @parent: dentry of parent directory, NULL for root directory
  44. * @buf: pointer to chan buffer
  45. *
  46. * Returns file dentry pointer if successful, NULL otherwise.
  47. */
  48. struct qal_dentry_t *
  49. qal_streamfs_create_file(const char *name, uint16_t mode,
  50. struct qal_dentry_t *parent,
  51. struct qal_streamfs_chan_buf *buf);
  52. /**
  53. * qal_streamfs_remove_dir_recursive() - Remove streamfs directory recursive
  54. * @d: dentry of the directory
  55. */
  56. void qal_streamfs_remove_dir_recursive(struct qal_dentry_t *d);
  57. /**
  58. * qal_streamfs_remove_dir() - Remove streamfs directory
  59. * @d: dentry of the directory
  60. */
  61. void qal_streamfs_remove_dir(struct qal_dentry_t *d);
  62. /**
  63. * qal_streamfs_remove_file() - Remove streamfs chan buffer file
  64. * @d: dentry of the buffer file
  65. */
  66. void qal_streamfs_remove_file(struct qal_dentry_t *d);
  67. /**
  68. * qal_streamfs_open() - Create streamfs channel for data trasfer
  69. * @base_filename: base name of files to create, %NULL for buffering only
  70. * @parent: dentry of parent directory, %NULL for root directory
  71. * @subbuf_size: size of sub-buffers
  72. * @n_subbufs: number of sub-buffers
  73. * @cb: streamfs channel callback functions
  74. * @private_data: user-defined data
  75. *
  76. * Returns channel pointer if successful, %NULL otherwise.
  77. */
  78. struct qal_streamfs_chan *
  79. qal_streamfs_open(const char *base_filename,
  80. struct qal_dentry_t *parent,
  81. size_t subbuf_size, size_t n_subbufs,
  82. struct qal_streamfs_chan_callbacks *cb,
  83. void *private_data);
  84. /**
  85. * qal_streamfs_close() - Closes all channel buffers and frees the channel.
  86. * @chan: pointer to qal_streamfs_chan.
  87. *
  88. * Returns NONE
  89. */
  90. void qal_streamfs_close(struct qal_streamfs_chan *chan);
  91. /**
  92. * qal_streamfs_flush() - Flushes all channel buffers.
  93. * @chan: pointer to qal_streamfs_chan.
  94. *
  95. * Returns NONE
  96. */
  97. void qal_streamfs_flush(struct qal_streamfs_chan *chan);
  98. /**
  99. * qal_streamfs_reset - reset streamfs channel
  100. * This erases data from all channel buffers and restarting the channel
  101. * in its initial state.
  102. * The buffers are not freed, so any mappings are still in effect.
  103. * @chan: pointer to qal_streamfs_chan.
  104. *
  105. * Returns NONE
  106. */
  107. void qal_streamfs_reset(struct qal_streamfs_chan *chan);
  108. /**
  109. * qal_streamfs_subbufs_consumed - update the buffer's sub-buffers-consumed
  110. * count
  111. * @chan: pointer to qal_streamfs_chan.
  112. * @cpu: the cpu associated with the channel buffer to update
  113. * @subbufs_consumed: number of sub-buffers to add to current buf's count
  114. *
  115. * Returns NONE
  116. */
  117. void qal_streamfs_subbufs_consumed(struct qal_streamfs_chan *chan,
  118. unsigned int cpu,
  119. size_t consumed);
  120. /**
  121. * qal_streamfs_write - write data into the channel
  122. * @chan: relay channel
  123. * @data: data to be written
  124. * @length: number of bytes to write
  125. *
  126. * Writes data into the current cpu's channel buffer.
  127. */
  128. void qal_streamfs_write(struct qal_streamfs_chan *chan, const void *data,
  129. size_t length);
  130. /**
  131. * qal_streamfs_buf_full - boolean, is the channel buffer full?
  132. * @buf: channel buffer
  133. *
  134. * Returns 1 if the buffer is full, 0 otherwise.
  135. */
  136. int qal_streamfs_buf_full(struct qal_streamfs_chan_buf *buf);
  137. #endif