28 #include <linux/slab.h>
29 #include <linux/netdevice.h>
30 #include <linux/pci.h>
42 static struct dentry *rootdir;
67 #define fappend(fmt, x...) \
69 if (bufsize - count) \
70 count += snprintf(buf + count, \
74 printk(KERN_ERR "b43legacy: fappend overflow\n"); \
86 (
unsigned int)((tsf & 0xFFFFFFFF00000000ULL) >> 32),
87 (
unsigned int)(tsf & 0xFFFFFFFFULL));
97 if (
sscanf(buf,
"%llu", (
unsigned long long *)(&tsf)) != 1)
110 for (i = 0; i < 64; i++) {
126 for (i = 0; i < 0x1000; i++) {
127 if (bufsize <
sizeof(tmp))
131 count +=
sizeof(
tmp);
132 bufsize -=
sizeof(
tmp);
140 struct b43legacy_txstatus_log *
log = &dev->dfsentry->txstatlog;
148 fappend(
"Nothing transmitted, yet\n");
151 fappend(
"b43legacy TX status reports:\n\n"
152 "index | cookie | seq | phy_stat | frame_count | "
153 "rts_count | supp_reason | pm_indicated | "
154 "intermediate | for_ampdu | acked\n" "---\n");
158 if (i == B43legacy_NR_LOGGED_TXSTATUS)
160 stat = &(log->log[
i]);
163 "0x%04X | 0x%04X | 0x%02X | "
180 spin_unlock_irqrestore(&log->lock, flags);
186 static int restart_write_file(
struct b43legacy_wldev *dev,
const char *buf,
size_t count)
190 if (count > 0 && buf[0] ==
'1') {
200 static ssize_t b43legacy_debugfs_read(
struct file *
file,
char __user *userbuf,
201 size_t count, loff_t *ppos)
205 struct b43legacy_dfs_file *dfile;
208 const size_t bufsize = 1024 * 16;
209 const size_t buforder =
get_order(bufsize);
229 dfile = fops_to_dfs_file(dev, dfops);
231 if (!dfile->buffer) {
239 spin_lock_irq(&dev->
wl->irq_lock);
240 ret = dfops->
read(dev, buf, bufsize);
241 spin_unlock_irq(&dev->
wl->irq_lock);
243 ret = dfops->
read(dev, buf, bufsize);
249 dfile->data_len =
ret;
256 if (*ppos >= dfile->data_len) {
257 free_pages((
unsigned long)dfile->buffer, buforder);
258 dfile->buffer =
NULL;
264 return err ? err :
ret;
267 static ssize_t b43legacy_debugfs_write(
struct file *file,
268 const char __user *userbuf,
269 size_t count, loff_t *ppos)
306 spin_lock_irq(&dev->
wl->irq_lock);
307 err = dfops->
write(dev, buf, count);
308 spin_unlock_irq(&dev->
wl->irq_lock);
310 err = dfops->
write(dev, buf, count);
319 return err ? err :
count;
323 #define B43legacy_DEBUGFS_FOPS(name, _read, _write, _take_irqlock) \
324 static struct b43legacy_debugfs_fops fops_##name = { \
328 .open = simple_open, \
329 .read = b43legacy_debugfs_read, \
330 .write = b43legacy_debugfs_write, \
331 .llseek = generic_file_llseek, \
333 .file_struct_offset = offsetof(struct b43legacy_dfsentry, \
335 .take_irqlock = _take_irqlock, \
347 return !!(dev->dfsentry && dev->dfsentry->dyn_debug[
feature]);
350 static void b43legacy_remove_dynamic_debug(
struct b43legacy_wldev *dev)
352 struct b43legacy_dfsentry *
e = dev->dfsentry;
361 struct b43legacy_dfsentry *e = dev->dfsentry;
364 #define add_dyn_dbg(name, id, initstate) do { \
365 e->dyn_debug[id] = (initstate); \
366 d = debugfs_create_bool(name, 0600, e->subdir, \
367 &(e->dyn_debug[id])); \
369 e->dyn_debug_dentries[id] = d; \
383 struct b43legacy_dfsentry *
e;
384 struct b43legacy_txstatus_log *
log;
395 log->log = kcalloc(B43legacy_NR_LOGGED_TXSTATUS,
407 snprintf(devdir,
sizeof(devdir),
"%s", wiphy_name(dev->
wl->hw->wiphy));
409 if (!e->subdir || IS_ERR(e->subdir)) {
410 if (e->subdir == ERR_PTR(-
ENODEV)) {
412 "enabled in kernel config\n");
417 dev->dfsentry =
NULL;
423 #define ADD_FILE(name, mode) \
426 d = debugfs_create_file(__stringify(name), \
427 mode, e->subdir, dev, \
428 &fops_##name.fops); \
429 e->file_##name.dentry = NULL; \
431 e->file_##name.dentry = d; \
443 b43legacy_add_dynamic_debug(dev);
448 struct b43legacy_dfsentry *
e;
455 b43legacy_remove_dynamic_debug(dev);
464 kfree(e->txstatlog.log);
471 struct b43legacy_dfsentry *e = dev->dfsentry;
472 struct b43legacy_txstatus_log *
log;
480 spin_lock(&log->lock);
482 if (i == B43legacy_NR_LOGGED_TXSTATUS)
485 cur = &(log->log[
i]);
486 memcpy(cur, status,
sizeof(*cur));
487 spin_unlock(&log->lock);