2 * Copyright (c) 2014 Redpine Signals Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include "rsi_debugfs.h"
21 * rsi_sdio_stats_read() - This function returns the sdio status of the driver.
22 * @seq: Pointer to the sequence file structure.
23 * @data: Pointer to the data.
25 * Return: 0 on success, -1 on failure.
27 static int rsi_sdio_stats_read(struct seq_file *seq, void *data)
29 struct rsi_common *common = seq->private;
30 struct rsi_hw *adapter = common->priv;
31 struct rsi_91x_sdiodev *dev =
32 (struct rsi_91x_sdiodev *)adapter->rsi_dev;
34 seq_printf(seq, "total_sdio_interrupts: %d\n",
35 dev->rx_info.sdio_int_counter);
36 seq_printf(seq, "sdio_msdu_pending_intr_count: %d\n",
37 dev->rx_info.total_sdio_msdu_pending_intr);
38 seq_printf(seq, "sdio_buff_full_count : %d\n",
39 dev->rx_info.buf_full_counter);
40 seq_printf(seq, "sdio_buf_semi_full_count %d\n",
41 dev->rx_info.buf_semi_full_counter);
42 seq_printf(seq, "sdio_unknown_intr_count: %d\n",
43 dev->rx_info.total_sdio_unknown_intr);
45 seq_printf(seq, "BUFFER FULL STATUS : %d\n",
46 dev->rx_info.buffer_full);
47 seq_printf(seq, "SEMI BUFFER FULL STATUS : %d\n",
48 dev->rx_info.semi_buffer_full);
49 seq_printf(seq, "MGMT BUFFER FULL STATUS : %d\n",
50 dev->rx_info.mgmt_buffer_full);
51 seq_printf(seq, "BUFFER FULL COUNTER : %d\n",
52 dev->rx_info.buf_full_counter);
53 seq_printf(seq, "BUFFER SEMI FULL COUNTER : %d\n",
54 dev->rx_info.buf_semi_full_counter);
55 seq_printf(seq, "MGMT BUFFER FULL COUNTER : %d\n",
56 dev->rx_info.mgmt_buf_full_counter);
62 * rsi_sdio_stats_open() - This funtion calls single open function of seq_file
63 * to open file and read contents from it.
64 * @inode: Pointer to the inode structure.
65 * @file: Pointer to the file structure.
67 * Return: Pointer to the opened file status: 0 on success, ENOMEM on failure.
69 static int rsi_sdio_stats_open(struct inode *inode,
72 return single_open(file, rsi_sdio_stats_read, inode->i_private);
76 * rsi_version_read() - This function gives driver and firmware version number.
77 * @seq: Pointer to the sequence file structure.
78 * @data: Pointer to the data.
80 * Return: 0 on success, -1 on failure.
82 static int rsi_version_read(struct seq_file *seq, void *data)
84 struct rsi_common *common = seq->private;
86 common->driver_ver.major = 0;
87 common->driver_ver.minor = 1;
88 common->driver_ver.release_num = 0;
89 common->driver_ver.patch_num = 0;
90 seq_printf(seq, "Driver : %x.%d.%d.%d\nLMAC : %d.%d.%d.%d\n",
91 common->driver_ver.major,
92 common->driver_ver.minor,
93 common->driver_ver.release_num,
94 common->driver_ver.patch_num,
97 common->fw_ver.release_num,
98 common->fw_ver.patch_num);
103 * rsi_version_open() - This funtion calls single open function of seq_file to
104 * open file and read contents from it.
105 * @inode: Pointer to the inode structure.
106 * @file: Pointer to the file structure.
108 * Return: Pointer to the opened file status: 0 on success, ENOMEM on failure.
110 static int rsi_version_open(struct inode *inode,
113 return single_open(file, rsi_version_read, inode->i_private);
117 * rsi_stats_read() - This function return the status of the driver.
118 * @seq: Pointer to the sequence file structure.
119 * @data: Pointer to the data.
121 * Return: 0 on success, -1 on failure.
123 static int rsi_stats_read(struct seq_file *seq, void *data)
125 struct rsi_common *common = seq->private;
127 unsigned char fsm_state[][32] = {
129 "FSM_CARD_NOT_READY",
130 "FSM_COMMON_DEV_PARAMS_SENT",
131 "FSM_BOOT_PARAMS_SENT",
132 "FSM_EEPROM_READ_MAC_ADDR",
133 "FSM_EEPROM_READ_RF_TYPE",
134 "FSM_RESET_MAC_SENT",
135 "FSM_RADIO_CAPS_SENT",
136 "FSM_BB_RF_PROG_SENT",
139 seq_puts(seq, "==> RSI STA DRIVER STATUS <==\n");
140 seq_puts(seq, "DRIVER_FSM_STATE: ");
142 BUILD_BUG_ON(ARRAY_SIZE(fsm_state) != NUM_FSM_STATES);
144 if (common->fsm_state <= FSM_MAC_INIT_DONE)
145 seq_printf(seq, "%s", fsm_state[common->fsm_state]);
147 seq_printf(seq, "(%d)\n\n", common->fsm_state);
149 /* Mgmt TX Path Stats */
150 seq_printf(seq, "total_mgmt_pkt_send : %d\n",
151 common->tx_stats.total_tx_pkt_send[MGMT_SOFT_Q]);
152 seq_printf(seq, "total_mgmt_pkt_queued : %d\n",
153 skb_queue_len(&common->tx_queue[MGMT_SOFT_Q]));
154 seq_printf(seq, "total_mgmt_pkt_freed : %d\n",
155 common->tx_stats.total_tx_pkt_freed[MGMT_SOFT_Q]);
157 /* Data TX Path Stats */
158 seq_printf(seq, "total_data_vo_pkt_send: %8d\t",
159 common->tx_stats.total_tx_pkt_send[VO_Q]);
160 seq_printf(seq, "total_data_vo_pkt_queued: %8d\t",
161 skb_queue_len(&common->tx_queue[VO_Q]));
162 seq_printf(seq, "total_vo_pkt_freed: %8d\n",
163 common->tx_stats.total_tx_pkt_freed[VO_Q]);
164 seq_printf(seq, "total_data_vi_pkt_send: %8d\t",
165 common->tx_stats.total_tx_pkt_send[VI_Q]);
166 seq_printf(seq, "total_data_vi_pkt_queued: %8d\t",
167 skb_queue_len(&common->tx_queue[VI_Q]));
168 seq_printf(seq, "total_vi_pkt_freed: %8d\n",
169 common->tx_stats.total_tx_pkt_freed[VI_Q]);
170 seq_printf(seq, "total_data_be_pkt_send: %8d\t",
171 common->tx_stats.total_tx_pkt_send[BE_Q]);
172 seq_printf(seq, "total_data_be_pkt_queued: %8d\t",
173 skb_queue_len(&common->tx_queue[BE_Q]));
174 seq_printf(seq, "total_be_pkt_freed: %8d\n",
175 common->tx_stats.total_tx_pkt_freed[BE_Q]);
176 seq_printf(seq, "total_data_bk_pkt_send: %8d\t",
177 common->tx_stats.total_tx_pkt_send[BK_Q]);
178 seq_printf(seq, "total_data_bk_pkt_queued: %8d\t",
179 skb_queue_len(&common->tx_queue[BK_Q]));
180 seq_printf(seq, "total_bk_pkt_freed: %8d\n",
181 common->tx_stats.total_tx_pkt_freed[BK_Q]);
188 * rsi_stats_open() - This funtion calls single open function of seq_file to
189 * open file and read contents from it.
190 * @inode: Pointer to the inode structure.
191 * @file: Pointer to the file structure.
193 * Return: Pointer to the opened file status: 0 on success, ENOMEM on failure.
195 static int rsi_stats_open(struct inode *inode,
198 return single_open(file, rsi_stats_read, inode->i_private);
202 * rsi_debug_zone_read() - This function display the currently enabled debug zones.
203 * @seq: Pointer to the sequence file structure.
204 * @data: Pointer to the data.
206 * Return: 0 on success, -1 on failure.
208 static int rsi_debug_zone_read(struct seq_file *seq, void *data)
210 rsi_dbg(FSM_ZONE, "%x: rsi_enabled zone", rsi_zone_enabled);
211 seq_printf(seq, "The zones available are %#x\n",
217 * rsi_debug_read() - This funtion calls single open function of seq_file to
218 * open file and read contents from it.
219 * @inode: Pointer to the inode structure.
220 * @file: Pointer to the file structure.
222 * Return: Pointer to the opened file status: 0 on success, ENOMEM on failure.
224 static int rsi_debug_read(struct inode *inode,
227 return single_open(file, rsi_debug_zone_read, inode->i_private);
231 * rsi_debug_zone_write() - This function writes into hal queues as per user
233 * @filp: Pointer to the file structure.
234 * @buff: Pointer to the character buffer.
235 * @len: Length of the data to be written into buffer.
236 * @data: Pointer to the data.
238 * Return: len: Number of bytes read.
240 static ssize_t rsi_debug_zone_write(struct file *filp,
241 const char __user *buff,
245 unsigned long dbg_zone;
251 ret = kstrtoul_from_user(buff, len, 16, &dbg_zone);
256 rsi_zone_enabled = dbg_zone;
260 #define FOPS(fopen) { \
261 .owner = THIS_MODULE, \
264 .llseek = seq_lseek, \
267 #define FOPS_RW(fopen, fwrite) { \
268 .owner = THIS_MODULE, \
271 .llseek = seq_lseek, \
275 static const struct rsi_dbg_files dev_debugfs_files[] = {
276 {"version", 0644, FOPS(rsi_version_open),},
277 {"stats", 0644, FOPS(rsi_stats_open),},
278 {"debug_zone", 0666, FOPS_RW(rsi_debug_read, rsi_debug_zone_write),},
279 {"sdio_stats", 0644, FOPS(rsi_sdio_stats_open),},
283 * rsi_init_dbgfs() - This function initializes the dbgfs entry.
284 * @adapter: Pointer to the adapter structure.
286 * Return: 0 on success, -1 on failure.
288 int rsi_init_dbgfs(struct rsi_hw *adapter)
290 struct rsi_common *common = adapter->priv;
291 struct rsi_debugfs *dev_dbgfs;
294 const struct rsi_dbg_files *files;
296 dev_dbgfs = kzalloc(sizeof(*dev_dbgfs), GFP_KERNEL);
300 adapter->dfsentry = dev_dbgfs;
302 snprintf(devdir, sizeof(devdir), "%s",
303 wiphy_name(adapter->hw->wiphy));
305 dev_dbgfs->subdir = debugfs_create_dir(devdir, NULL);
307 if (!dev_dbgfs->subdir) {
312 for (ii = 0; ii < adapter->num_debugfs_entries; ii++) {
313 files = &dev_debugfs_files[ii];
314 dev_dbgfs->rsi_files[ii] =
315 debugfs_create_file(files->name,
323 EXPORT_SYMBOL_GPL(rsi_init_dbgfs);
326 * rsi_remove_dbgfs() - Removes the previously created dbgfs file entries
327 * in the reverse order of creation.
328 * @adapter: Pointer to the adapter structure.
332 void rsi_remove_dbgfs(struct rsi_hw *adapter)
334 struct rsi_debugfs *dev_dbgfs = adapter->dfsentry;
339 debugfs_remove_recursive(dev_dbgfs->subdir);
341 EXPORT_SYMBOL_GPL(rsi_remove_dbgfs);