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