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