Blame view
net/mac80211/rc80211_pid_debugfs.c
5.91 KB
12446c67f rc80211-pid: add ... |
1 2 3 4 5 6 7 |
/* * Copyright 2007, Mattias Nissler <mattias.nissler@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ |
d43c36dc6 headers: remove s... |
8 |
#include <linux/sched.h> |
12446c67f rc80211-pid: add ... |
9 10 11 12 13 |
#include <linux/spinlock.h> #include <linux/poll.h> #include <linux/netdevice.h> #include <linux/types.h> #include <linux/skbuff.h> |
5a0e3ad6a include cleanup: ... |
14 |
#include <linux/slab.h> |
bc3b2d7fb net: Add export.h... |
15 |
#include <linux/export.h> |
12446c67f rc80211-pid: add ... |
16 17 |
#include <net/mac80211.h> |
2c8dccc77 mac80211: rename ... |
18 |
#include "rate.h" |
12446c67f rc80211-pid: add ... |
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include "rc80211_pid.h" static void rate_control_pid_event(struct rc_pid_event_buffer *buf, enum rc_pid_event_type type, union rc_pid_event_data *data) { struct rc_pid_event *ev; unsigned long status; spin_lock_irqsave(&buf->lock, status); ev = &(buf->ring[buf->next_entry]); buf->next_entry = (buf->next_entry + 1) % RC_PID_EVENT_RING_SIZE; ev->timestamp = jiffies; ev->id = buf->ev_count++; ev->type = type; ev->data = *data; spin_unlock_irqrestore(&buf->lock, status); wake_up_all(&buf->waitqueue); } void rate_control_pid_event_tx_status(struct rc_pid_event_buffer *buf, |
e039fa4a4 mac80211: move TX... |
44 |
struct ieee80211_tx_info *stat) |
12446c67f rc80211-pid: add ... |
45 46 |
{ union rc_pid_event_data evd; |
e6a9854b0 mac80211/drivers:... |
47 |
evd.flags = stat->flags; |
e039fa4a4 mac80211: move TX... |
48 |
memcpy(&evd.tx_status, stat, sizeof(struct ieee80211_tx_info)); |
12446c67f rc80211-pid: add ... |
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
rate_control_pid_event(buf, RC_PID_EVENT_TYPE_TX_STATUS, &evd); } void rate_control_pid_event_rate_change(struct rc_pid_event_buffer *buf, int index, int rate) { union rc_pid_event_data evd; evd.index = index; evd.rate = rate; rate_control_pid_event(buf, RC_PID_EVENT_TYPE_RATE_CHANGE, &evd); } void rate_control_pid_event_tx_rate(struct rc_pid_event_buffer *buf, int index, int rate) { union rc_pid_event_data evd; evd.index = index; evd.rate = rate; rate_control_pid_event(buf, RC_PID_EVENT_TYPE_TX_RATE, &evd); } void rate_control_pid_event_pf_sample(struct rc_pid_event_buffer *buf, s32 pf_sample, s32 prop_err, s32 int_err, s32 der_err) { union rc_pid_event_data evd; evd.pf_sample = pf_sample; evd.prop_err = prop_err; evd.int_err = int_err; evd.der_err = der_err; rate_control_pid_event(buf, RC_PID_EVENT_TYPE_PF_SAMPLE, &evd); } static int rate_control_pid_events_open(struct inode *inode, struct file *file) { struct rc_pid_sta_info *sinfo = inode->i_private; struct rc_pid_event_buffer *events = &sinfo->events; struct rc_pid_events_file_info *file_info; |
a1f2aa1be fix irq flags in ... |
90 |
unsigned long status; |
12446c67f rc80211-pid: add ... |
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
/* Allocate a state struct */ file_info = kmalloc(sizeof(*file_info), GFP_KERNEL); if (file_info == NULL) return -ENOMEM; spin_lock_irqsave(&events->lock, status); file_info->next_entry = events->next_entry; file_info->events = events; spin_unlock_irqrestore(&events->lock, status); file->private_data = file_info; return 0; } static int rate_control_pid_events_release(struct inode *inode, struct file *file) { struct rc_pid_events_file_info *file_info = file->private_data; kfree(file_info); return 0; } static unsigned int rate_control_pid_events_poll(struct file *file, poll_table *wait) { struct rc_pid_events_file_info *file_info = file->private_data; poll_wait(file, &file_info->events->waitqueue, wait); return POLLIN | POLLRDNORM; } #define RC_PID_PRINT_BUF_SIZE 64 static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf, size_t length, loff_t *offset) { struct rc_pid_events_file_info *file_info = file->private_data; struct rc_pid_event_buffer *events = file_info->events; struct rc_pid_event *ev; char pb[RC_PID_PRINT_BUF_SIZE]; int ret; int p; |
a1f2aa1be fix irq flags in ... |
140 |
unsigned long status; |
12446c67f rc80211-pid: add ... |
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
/* Check if there is something to read. */ if (events->next_entry == file_info->next_entry) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; /* Wait */ ret = wait_event_interruptible(events->waitqueue, events->next_entry != file_info->next_entry); if (ret) return ret; } /* Write out one event per call. I don't care whether it's a little * inefficient, this is debugging code anyway. */ spin_lock_irqsave(&events->lock, status); /* Get an event */ ev = &(events->ring[file_info->next_entry]); file_info->next_entry = (file_info->next_entry + 1) % RC_PID_EVENT_RING_SIZE; |
1fdaa46e9 net: mac80211: Fi... |
163 |
/* Print information about the event. Note that userspace needs to |
12446c67f rc80211-pid: add ... |
164 165 166 167 168 169 170 |
* provide large enough buffers. */ length = length < RC_PID_PRINT_BUF_SIZE ? length : RC_PID_PRINT_BUF_SIZE; p = snprintf(pb, length, "%u %lu ", ev->id, ev->timestamp); switch (ev->type) { case RC_PID_EVENT_TYPE_TX_STATUS: p += snprintf(pb + p, length - p, "tx_status %u %u", |
e6a9854b0 mac80211/drivers:... |
171 172 |
!(ev->data.flags & IEEE80211_TX_STAT_ACK), ev->data.tx_status.status.rates[0].idx); |
12446c67f rc80211-pid: add ... |
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
break; case RC_PID_EVENT_TYPE_RATE_CHANGE: p += snprintf(pb + p, length - p, "rate_change %d %d", ev->data.index, ev->data.rate); break; case RC_PID_EVENT_TYPE_TX_RATE: p += snprintf(pb + p, length - p, "tx_rate %d %d", ev->data.index, ev->data.rate); break; case RC_PID_EVENT_TYPE_PF_SAMPLE: p += snprintf(pb + p, length - p, "pf_sample %d %d %d %d", ev->data.pf_sample, ev->data.prop_err, ev->data.int_err, ev->data.der_err); break; } p += snprintf(pb + p, length - p, " "); spin_unlock_irqrestore(&events->lock, status); if (copy_to_user(buf, pb, p)) return -EFAULT; return p; } #undef RC_PID_PRINT_BUF_SIZE |
5ca1b998d net: file_operati... |
201 |
static const struct file_operations rc_pid_fop_events = { |
12446c67f rc80211-pid: add ... |
202 203 204 205 206 |
.owner = THIS_MODULE, .read = rate_control_pid_events_read, .poll = rate_control_pid_events_poll, .open = rate_control_pid_events_open, .release = rate_control_pid_events_release, |
6038f373a llseek: automatic... |
207 |
.llseek = noop_llseek, |
12446c67f rc80211-pid: add ... |
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
}; void rate_control_pid_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir) { struct rc_pid_sta_info *spinfo = priv_sta; spinfo->events_entry = debugfs_create_file("rc_pid_events", S_IRUGO, dir, spinfo, &rc_pid_fop_events); } void rate_control_pid_remove_sta_debugfs(void *priv, void *priv_sta) { struct rc_pid_sta_info *spinfo = priv_sta; debugfs_remove(spinfo->events_entry); } |