Skip to content

Commit abfbc3a

Browse files
committed
mac80211: remove TX latency measurement code
Revert commit ad38bfc ("mac80211: Tx frame latency statistics") (along with some follow-up fixes). This code turned out not to be as useful in the current form as we thought, and we've internally hacked it up more, but that's not very suitable for upstream (for now), and we might just do that with tracing instead. Therefore, for now at least, remove this code. We might also need to use the skb->tstamp field for the TCP performance issue, which is more important than the debugging. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 31f909a commit abfbc3a

8 files changed

Lines changed: 5 additions & 495 deletions

File tree

‎net/mac80211/debugfs.c‎

Lines changed: 0 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -18,172 +18,6 @@
1818

1919
#define DEBUGFS_FORMAT_BUFFER_SIZE 100
2020

21-
#define TX_LATENCY_BIN_DELIMTER_C ','
22-
#define TX_LATENCY_BIN_DELIMTER_S ","
23-
#define TX_LATENCY_BINS_DISABLED "enable(bins disabled)\n"
24-
#define TX_LATENCY_DISABLED "disable\n"
25-
26-
27-
/*
28-
* Display if Tx latency statistics & bins are enabled/disabled
29-
*/
30-
static ssize_t sta_tx_latency_stat_read(struct file *file,
31-
char __user *userbuf,
32-
size_t count, loff_t *ppos)
33-
{
34-
struct ieee80211_local *local = file->private_data;
35-
struct ieee80211_tx_latency_bin_ranges *tx_latency;
36-
char *buf;
37-
int bufsz, i, ret;
38-
int pos = 0;
39-
40-
rcu_read_lock();
41-
42-
tx_latency = rcu_dereference(local->tx_latency);
43-
44-
if (tx_latency && tx_latency->n_ranges) {
45-
bufsz = tx_latency->n_ranges * 15;
46-
buf = kzalloc(bufsz, GFP_ATOMIC);
47-
if (!buf)
48-
goto err;
49-
50-
for (i = 0; i < tx_latency->n_ranges; i++)
51-
pos += scnprintf(buf + pos, bufsz - pos, "%d,",
52-
tx_latency->ranges[i]);
53-
pos += scnprintf(buf + pos, bufsz - pos, "\n");
54-
} else if (tx_latency) {
55-
bufsz = sizeof(TX_LATENCY_BINS_DISABLED) + 1;
56-
buf = kzalloc(bufsz, GFP_ATOMIC);
57-
if (!buf)
58-
goto err;
59-
60-
pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
61-
TX_LATENCY_BINS_DISABLED);
62-
} else {
63-
bufsz = sizeof(TX_LATENCY_DISABLED) + 1;
64-
buf = kzalloc(bufsz, GFP_ATOMIC);
65-
if (!buf)
66-
goto err;
67-
68-
pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
69-
TX_LATENCY_DISABLED);
70-
}
71-
72-
rcu_read_unlock();
73-
74-
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
75-
kfree(buf);
76-
77-
return ret;
78-
err:
79-
rcu_read_unlock();
80-
return -ENOMEM;
81-
}
82-
83-
/*
84-
* Receive input from user regarding Tx latency statistics
85-
* The input should indicate if Tx latency statistics and bins are
86-
* enabled/disabled.
87-
* If bins are enabled input should indicate the amount of different bins and
88-
* their ranges. Each bin will count how many Tx frames transmitted within the
89-
* appropriate latency.
90-
* Legal input is:
91-
* a) "enable(bins disabled)" - to enable only general statistics
92-
* b) "a,b,c,d,...z" - to enable general statistics and bins, where all are
93-
* numbers and a < b < c < d.. < z
94-
* c) "disable" - disable all statistics
95-
* NOTE: must configure Tx latency statistics bins before stations connected.
96-
*/
97-
98-
static ssize_t sta_tx_latency_stat_write(struct file *file,
99-
const char __user *userbuf,
100-
size_t count, loff_t *ppos)
101-
{
102-
struct ieee80211_local *local = file->private_data;
103-
char buf[128] = {};
104-
char *bins = buf;
105-
char *token;
106-
int buf_size, i, alloc_size;
107-
int prev_bin = 0;
108-
int n_ranges = 0;
109-
int ret = count;
110-
struct ieee80211_tx_latency_bin_ranges *tx_latency;
111-
112-
if (sizeof(buf) <= count)
113-
return -EINVAL;
114-
buf_size = count;
115-
if (copy_from_user(buf, userbuf, buf_size))
116-
return -EFAULT;
117-
118-
mutex_lock(&local->sta_mtx);
119-
120-
/* cannot change config once we have stations */
121-
if (local->num_sta)
122-
goto unlock;
123-
124-
tx_latency =
125-
rcu_dereference_protected(local->tx_latency,
126-
lockdep_is_held(&local->sta_mtx));
127-
128-
/* disable Tx statistics */
129-
if (!strcmp(buf, TX_LATENCY_DISABLED)) {
130-
if (!tx_latency)
131-
goto unlock;
132-
RCU_INIT_POINTER(local->tx_latency, NULL);
133-
synchronize_rcu();
134-
kfree(tx_latency);
135-
goto unlock;
136-
}
137-
138-
/* Tx latency already enabled */
139-
if (tx_latency)
140-
goto unlock;
141-
142-
if (strcmp(TX_LATENCY_BINS_DISABLED, buf)) {
143-
/* check how many bins and between what ranges user requested */
144-
token = buf;
145-
while (*token != '\0') {
146-
if (*token == TX_LATENCY_BIN_DELIMTER_C)
147-
n_ranges++;
148-
token++;
149-
}
150-
n_ranges++;
151-
}
152-
153-
alloc_size = sizeof(struct ieee80211_tx_latency_bin_ranges) +
154-
n_ranges * sizeof(u32);
155-
tx_latency = kzalloc(alloc_size, GFP_ATOMIC);
156-
if (!tx_latency) {
157-
ret = -ENOMEM;
158-
goto unlock;
159-
}
160-
tx_latency->n_ranges = n_ranges;
161-
for (i = 0; i < n_ranges; i++) { /* setting bin ranges */
162-
token = strsep(&bins, TX_LATENCY_BIN_DELIMTER_S);
163-
sscanf(token, "%d", &tx_latency->ranges[i]);
164-
/* bins values should be in ascending order */
165-
if (prev_bin >= tx_latency->ranges[i]) {
166-
ret = -EINVAL;
167-
kfree(tx_latency);
168-
goto unlock;
169-
}
170-
prev_bin = tx_latency->ranges[i];
171-
}
172-
rcu_assign_pointer(local->tx_latency, tx_latency);
173-
174-
unlock:
175-
mutex_unlock(&local->sta_mtx);
176-
177-
return ret;
178-
}
179-
180-
static const struct file_operations stats_tx_latency_ops = {
181-
.write = sta_tx_latency_stat_write,
182-
.read = sta_tx_latency_stat_read,
183-
.open = simple_open,
184-
.llseek = generic_file_llseek,
185-
};
186-
18721
int mac80211_format_buffer(char __user *userbuf, size_t count,
18822
loff_t *ppos, char *fmt, ...)
18923
{
@@ -475,6 +309,4 @@ void debugfs_hw_add(struct ieee80211_local *local)
475309
DEBUGFS_DEVSTATS_ADD(dot11RTSFailureCount);
476310
DEBUGFS_DEVSTATS_ADD(dot11FCSErrorCount);
477311
DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount);
478-
479-
DEBUGFS_DEVSTATS_ADD(tx_latency);
480312
}

‎net/mac80211/debugfs_sta.c‎

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ static const struct file_operations sta_ ##name## _ops = { \
3939
.llseek = generic_file_llseek, \
4040
}
4141

42-
#define STA_OPS_W(name) \
43-
static const struct file_operations sta_ ##name## _ops = { \
44-
.write = sta_##name##_write, \
45-
.open = simple_open, \
46-
.llseek = generic_file_llseek, \
47-
}
48-
4942
#define STA_OPS_RW(name) \
5043
static const struct file_operations sta_ ##name## _ops = { \
5144
.read = sta_##name##_read, \
@@ -398,131 +391,6 @@ static ssize_t sta_last_rx_rate_read(struct file *file, char __user *userbuf,
398391
}
399392
STA_OPS(last_rx_rate);
400393

401-
static int
402-
sta_tx_latency_stat_header(struct ieee80211_tx_latency_bin_ranges *tx_latency,
403-
char *buf, int pos, int bufsz)
404-
{
405-
int i;
406-
int range_count = tx_latency->n_ranges;
407-
u32 *bin_ranges = tx_latency->ranges;
408-
409-
pos += scnprintf(buf + pos, bufsz - pos,
410-
"Station\t\t\tTID\tMax\tAvg");
411-
if (range_count) {
412-
pos += scnprintf(buf + pos, bufsz - pos,
413-
"\t<=%d", bin_ranges[0]);
414-
for (i = 0; i < range_count - 1; i++)
415-
pos += scnprintf(buf + pos, bufsz - pos, "\t%d-%d",
416-
bin_ranges[i], bin_ranges[i+1]);
417-
pos += scnprintf(buf + pos, bufsz - pos,
418-
"\t%d<", bin_ranges[range_count - 1]);
419-
}
420-
421-
pos += scnprintf(buf + pos, bufsz - pos, "\n");
422-
423-
return pos;
424-
}
425-
426-
static int
427-
sta_tx_latency_stat_table(struct ieee80211_tx_latency_bin_ranges *tx_lat_range,
428-
struct ieee80211_tx_latency_stat *tx_lat,
429-
char *buf, int pos, int bufsz, int tid)
430-
{
431-
u32 avg = 0;
432-
int j;
433-
int bin_count = tx_lat->bin_count;
434-
435-
pos += scnprintf(buf + pos, bufsz - pos, "\t\t\t%d", tid);
436-
/* make sure you don't divide in 0 */
437-
if (tx_lat->counter)
438-
avg = tx_lat->sum / tx_lat->counter;
439-
440-
pos += scnprintf(buf + pos, bufsz - pos, "\t%d\t%d",
441-
tx_lat->max, avg);
442-
443-
if (tx_lat_range->n_ranges && tx_lat->bins)
444-
for (j = 0; j < bin_count; j++)
445-
pos += scnprintf(buf + pos, bufsz - pos,
446-
"\t%d", tx_lat->bins[j]);
447-
pos += scnprintf(buf + pos, bufsz - pos, "\n");
448-
449-
return pos;
450-
}
451-
452-
/*
453-
* Output Tx latency statistics station && restart all statistics information
454-
*/
455-
static ssize_t sta_tx_latency_stat_read(struct file *file,
456-
char __user *userbuf,
457-
size_t count, loff_t *ppos)
458-
{
459-
struct sta_info *sta = file->private_data;
460-
struct ieee80211_local *local = sta->local;
461-
struct ieee80211_tx_latency_bin_ranges *tx_latency;
462-
char *buf;
463-
int bufsz, ret, i;
464-
int pos = 0;
465-
466-
bufsz = 20 * IEEE80211_NUM_TIDS *
467-
sizeof(struct ieee80211_tx_latency_stat);
468-
buf = kzalloc(bufsz, GFP_KERNEL);
469-
if (!buf)
470-
return -ENOMEM;
471-
472-
rcu_read_lock();
473-
474-
tx_latency = rcu_dereference(local->tx_latency);
475-
476-
if (!sta->tx_lat) {
477-
pos += scnprintf(buf + pos, bufsz - pos,
478-
"Tx latency statistics are not enabled\n");
479-
goto unlock;
480-
}
481-
482-
pos = sta_tx_latency_stat_header(tx_latency, buf, pos, bufsz);
483-
484-
pos += scnprintf(buf + pos, bufsz - pos, "%pM\n", sta->sta.addr);
485-
for (i = 0; i < IEEE80211_NUM_TIDS; i++)
486-
pos = sta_tx_latency_stat_table(tx_latency, &sta->tx_lat[i],
487-
buf, pos, bufsz, i);
488-
unlock:
489-
rcu_read_unlock();
490-
491-
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
492-
kfree(buf);
493-
494-
return ret;
495-
}
496-
STA_OPS(tx_latency_stat);
497-
498-
static ssize_t sta_tx_latency_stat_reset_write(struct file *file,
499-
const char __user *userbuf,
500-
size_t count, loff_t *ppos)
501-
{
502-
u32 *bins;
503-
int bin_count;
504-
struct sta_info *sta = file->private_data;
505-
int i;
506-
507-
if (!sta->tx_lat)
508-
return -EINVAL;
509-
510-
for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
511-
bins = sta->tx_lat[i].bins;
512-
bin_count = sta->tx_lat[i].bin_count;
513-
514-
sta->tx_lat[i].max = 0;
515-
sta->tx_lat[i].sum = 0;
516-
sta->tx_lat[i].counter = 0;
517-
518-
if (bin_count)
519-
memset(bins, 0, bin_count * sizeof(u32));
520-
}
521-
522-
return count;
523-
}
524-
STA_OPS_W(tx_latency_stat_reset);
525-
526394
#define DEBUGFS_ADD(name) \
527395
debugfs_create_file(#name, 0400, \
528396
sta->debugfs.dir, sta, &sta_ ##name## _ops);
@@ -576,8 +444,6 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
576444
DEBUGFS_ADD(last_ack_signal);
577445
DEBUGFS_ADD(current_tx_rate);
578446
DEBUGFS_ADD(last_rx_rate);
579-
DEBUGFS_ADD(tx_latency_stat);
580-
DEBUGFS_ADD(tx_latency_stat_reset);
581447

582448
DEBUGFS_ADD_COUNTER(rx_packets, rx_packets);
583449
DEBUGFS_ADD_COUNTER(tx_packets, tx_packets);

‎net/mac80211/ieee80211_i.h‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,24 +1030,6 @@ struct tpt_led_trigger {
10301030
};
10311031
#endif
10321032

1033-
/*
1034-
* struct ieee80211_tx_latency_bin_ranges - Tx latency statistics bins ranges
1035-
*
1036-
* Measuring Tx latency statistics. Counts how many Tx frames transmitted in a
1037-
* certain latency range (in Milliseconds). Each station that uses these
1038-
* ranges will have bins to count the amount of frames received in that range.
1039-
* The user can configure the ranges via debugfs.
1040-
* If ranges is NULL then Tx latency statistics bins are disabled for all
1041-
* stations.
1042-
*
1043-
* @n_ranges: number of ranges that are taken in account
1044-
* @ranges: the ranges that the user requested or NULL if disabled.
1045-
*/
1046-
struct ieee80211_tx_latency_bin_ranges {
1047-
int n_ranges;
1048-
u32 ranges[];
1049-
};
1050-
10511033
/**
10521034
* mac80211 scan flags - currently active scan mode
10531035
*
@@ -1199,12 +1181,6 @@ struct ieee80211_local {
11991181
struct timer_list sta_cleanup;
12001182
int sta_generation;
12011183

1202-
/*
1203-
* Tx latency statistics parameters for all stations.
1204-
* Can enable via debugfs (NULL when disabled).
1205-
*/
1206-
struct ieee80211_tx_latency_bin_ranges __rcu *tx_latency;
1207-
12081184
struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
12091185
struct tasklet_struct tx_pending_tasklet;
12101186

‎net/mac80211/main.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,8 +1201,6 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
12011201
ieee80211_free_ack_frame, NULL);
12021202
idr_destroy(&local->ack_status_frames);
12031203

1204-
kfree(rcu_access_pointer(local->tx_latency));
1205-
12061204
sta_info_stop(local);
12071205

12081206
wiphy_free(local->hw.wiphy);

0 commit comments

Comments
 (0)