Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2003-2005 Devicescape Software, Inc. |
| 3 | * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> |
| 4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
Johannes Berg | d98ad83 | 2014-09-03 15:24:57 +0300 | [diff] [blame] | 5 | * Copyright 2013-2014 Intel Mobile Communications GmbH |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 6 | * Copyright(c) 2016 Intel Deutschland GmbH |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 7 | * Copyright (C) 2018 Intel Corporation |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/debugfs.h> |
| 15 | #include <linux/ieee80211.h> |
| 16 | #include "ieee80211_i.h" |
| 17 | #include "debugfs.h" |
| 18 | #include "debugfs_sta.h" |
| 19 | #include "sta_info.h" |
Sujith Manoharan | 77d2ece | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 20 | #include "driver-ops.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 21 | |
| 22 | /* sta attributtes */ |
| 23 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 24 | #define STA_READ(name, field, format_string) \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 25 | static ssize_t sta_ ##name## _read(struct file *file, \ |
| 26 | char __user *userbuf, \ |
| 27 | size_t count, loff_t *ppos) \ |
| 28 | { \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 29 | struct sta_info *sta = file->private_data; \ |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 30 | return mac80211_format_buffer(userbuf, count, ppos, \ |
| 31 | format_string, sta->field); \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 32 | } |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 33 | #define STA_READ_D(name, field) STA_READ(name, field, "%d\n") |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 34 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 35 | #define STA_OPS(name) \ |
| 36 | static const struct file_operations sta_ ##name## _ops = { \ |
| 37 | .read = sta_##name##_read, \ |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 38 | .open = simple_open, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 39 | .llseek = generic_file_llseek, \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 42 | #define STA_OPS_RW(name) \ |
| 43 | static const struct file_operations sta_ ##name## _ops = { \ |
| 44 | .read = sta_##name##_read, \ |
| 45 | .write = sta_##name##_write, \ |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 46 | .open = simple_open, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 47 | .llseek = generic_file_llseek, \ |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 48 | } |
| 49 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 50 | #define STA_FILE(name, field, format) \ |
| 51 | STA_READ_##format(name, field) \ |
| 52 | STA_OPS(name) |
| 53 | |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 54 | STA_FILE(aid, sta.aid, D); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 55 | |
Johannes Berg | c84387d | 2016-03-17 15:02:54 +0200 | [diff] [blame] | 56 | static const char * const sta_flag_names[] = { |
| 57 | #define FLAG(F) [WLAN_STA_##F] = #F |
| 58 | FLAG(AUTH), |
| 59 | FLAG(ASSOC), |
| 60 | FLAG(PS_STA), |
| 61 | FLAG(AUTHORIZED), |
| 62 | FLAG(SHORT_PREAMBLE), |
| 63 | FLAG(WDS), |
| 64 | FLAG(CLEAR_PS_FILT), |
| 65 | FLAG(MFP), |
| 66 | FLAG(BLOCK_BA), |
| 67 | FLAG(PS_DRIVER), |
| 68 | FLAG(PSPOLL), |
| 69 | FLAG(TDLS_PEER), |
| 70 | FLAG(TDLS_PEER_AUTH), |
| 71 | FLAG(TDLS_INITIATOR), |
| 72 | FLAG(TDLS_CHAN_SWITCH), |
| 73 | FLAG(TDLS_OFF_CHANNEL), |
| 74 | FLAG(TDLS_WIDER_BW), |
| 75 | FLAG(UAPSD), |
| 76 | FLAG(SP), |
| 77 | FLAG(4ADDR_EVENT), |
| 78 | FLAG(INSERTED), |
| 79 | FLAG(RATE_CONTROL), |
| 80 | FLAG(TOFFSET_KNOWN), |
| 81 | FLAG(MPSP_OWNER), |
| 82 | FLAG(MPSP_RECIPIENT), |
| 83 | FLAG(PS_DELIVER), |
| 84 | #undef FLAG |
| 85 | }; |
| 86 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 87 | static ssize_t sta_flags_read(struct file *file, char __user *userbuf, |
| 88 | size_t count, loff_t *ppos) |
| 89 | { |
Johannes Berg | c84387d | 2016-03-17 15:02:54 +0200 | [diff] [blame] | 90 | char buf[16 * NUM_WLAN_STA_FLAGS], *pos = buf; |
| 91 | char *end = buf + sizeof(buf) - 1; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 92 | struct sta_info *sta = file->private_data; |
Johannes Berg | c84387d | 2016-03-17 15:02:54 +0200 | [diff] [blame] | 93 | unsigned int flg; |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 94 | |
Johannes Berg | c84387d | 2016-03-17 15:02:54 +0200 | [diff] [blame] | 95 | BUILD_BUG_ON(ARRAY_SIZE(sta_flag_names) != NUM_WLAN_STA_FLAGS); |
Johannes Berg | 5bade10 | 2011-09-29 16:04:37 +0200 | [diff] [blame] | 96 | |
Johannes Berg | c84387d | 2016-03-17 15:02:54 +0200 | [diff] [blame] | 97 | for (flg = 0; flg < NUM_WLAN_STA_FLAGS; flg++) { |
| 98 | if (test_sta_flag(sta, flg)) |
| 99 | pos += scnprintf(pos, end - pos, "%s\n", |
| 100 | sta_flag_names[flg]); |
| 101 | } |
| 102 | |
| 103 | return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 104 | } |
| 105 | STA_OPS(flags); |
| 106 | |
| 107 | static ssize_t sta_num_ps_buf_frames_read(struct file *file, |
| 108 | char __user *userbuf, |
| 109 | size_t count, loff_t *ppos) |
| 110 | { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 111 | struct sta_info *sta = file->private_data; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 112 | char buf[17*IEEE80211_NUM_ACS], *p = buf; |
| 113 | int ac; |
| 114 | |
| 115 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 116 | p += scnprintf(p, sizeof(buf)+buf-p, "AC%d: %d\n", ac, |
| 117 | skb_queue_len(&sta->ps_tx_buf[ac]) + |
| 118 | skb_queue_len(&sta->tx_filtered[ac])); |
| 119 | return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 120 | } |
| 121 | STA_OPS(num_ps_buf_frames); |
| 122 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 123 | static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf, |
| 124 | size_t count, loff_t *ppos) |
| 125 | { |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 126 | char buf[15*IEEE80211_NUM_TIDS], *p = buf; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 127 | int i; |
| 128 | struct sta_info *sta = file->private_data; |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 129 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 130 | p += scnprintf(p, sizeof(buf)+buf-p, "%x ", |
Zhu Yi | ba9b07d | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 131 | le16_to_cpu(sta->last_seq_ctrl[i])); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 132 | p += scnprintf(p, sizeof(buf)+buf-p, "\n"); |
| 133 | return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 134 | } |
| 135 | STA_OPS(last_seq_ctrl); |
| 136 | |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 137 | #define AQM_TXQ_ENTRY_LEN 130 |
| 138 | |
| 139 | static ssize_t sta_aqm_read(struct file *file, char __user *userbuf, |
| 140 | size_t count, loff_t *ppos) |
| 141 | { |
| 142 | struct sta_info *sta = file->private_data; |
| 143 | struct ieee80211_local *local = sta->local; |
Johannes Berg | adf8ed0 | 2018-08-31 11:31:08 +0300 | [diff] [blame] | 144 | size_t bufsz = AQM_TXQ_ENTRY_LEN * (IEEE80211_NUM_TIDS + 2); |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 145 | char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf; |
| 146 | struct txq_info *txqi; |
| 147 | ssize_t rv; |
| 148 | int i; |
| 149 | |
| 150 | if (!buf) |
| 151 | return -ENOMEM; |
| 152 | |
| 153 | spin_lock_bh(&local->fq.lock); |
| 154 | rcu_read_lock(); |
| 155 | |
| 156 | p += scnprintf(p, |
| 157 | bufsz+buf-p, |
Toke Høiland-Jørgensen | 484a54c | 2017-04-06 11:38:26 +0200 | [diff] [blame] | 158 | "target %uus interval %uus ecn %s\n", |
| 159 | codel_time_to_us(sta->cparams.target), |
| 160 | codel_time_to_us(sta->cparams.interval), |
| 161 | sta->cparams.ecn ? "yes" : "no"); |
| 162 | p += scnprintf(p, |
| 163 | bufsz+buf-p, |
Ben Greear | 25b0ba7 | 2018-01-26 17:14:19 -0800 | [diff] [blame] | 164 | "tid ac backlog-bytes backlog-packets new-flows drops marks overlimit collisions tx-bytes tx-packets flags\n"); |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 165 | |
Johannes Berg | adf8ed0 | 2018-08-31 11:31:08 +0300 | [diff] [blame] | 166 | for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { |
| 167 | if (!sta->sta.txq[i]) |
| 168 | continue; |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 169 | txqi = to_txq_info(sta->sta.txq[i]); |
| 170 | p += scnprintf(p, bufsz+buf-p, |
Ben Greear | 25b0ba7 | 2018-01-26 17:14:19 -0800 | [diff] [blame] | 171 | "%d %d %u %u %u %u %u %u %u %u %u 0x%lx(%s%s%s)\n", |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 172 | txqi->txq.tid, |
| 173 | txqi->txq.ac, |
| 174 | txqi->tin.backlog_bytes, |
| 175 | txqi->tin.backlog_packets, |
| 176 | txqi->tin.flows, |
| 177 | txqi->cstats.drop_count, |
| 178 | txqi->cstats.ecn_mark, |
| 179 | txqi->tin.overlimit, |
| 180 | txqi->tin.collisions, |
| 181 | txqi->tin.tx_bytes, |
Ben Greear | 25b0ba7 | 2018-01-26 17:14:19 -0800 | [diff] [blame] | 182 | txqi->tin.tx_packets, |
| 183 | txqi->flags, |
| 184 | txqi->flags & (1<<IEEE80211_TXQ_STOP) ? "STOP" : "RUN", |
| 185 | txqi->flags & (1<<IEEE80211_TXQ_AMPDU) ? " AMPDU" : "", |
| 186 | txqi->flags & (1<<IEEE80211_TXQ_NO_AMSDU) ? " NO-AMSDU" : ""); |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | rcu_read_unlock(); |
| 190 | spin_unlock_bh(&local->fq.lock); |
| 191 | |
| 192 | rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 193 | kfree(buf); |
| 194 | return rv; |
| 195 | } |
| 196 | STA_OPS(aqm); |
| 197 | |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 198 | static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, |
| 199 | size_t count, loff_t *ppos) |
| 200 | { |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 201 | char buf[71 + IEEE80211_NUM_TIDS * 40], *p = buf; |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 202 | int i; |
| 203 | struct sta_info *sta = file->private_data; |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 204 | struct tid_ampdu_rx *tid_rx; |
| 205 | struct tid_ampdu_tx *tid_tx; |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 206 | |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 207 | rcu_read_lock(); |
| 208 | |
Pavel Roskin | e0b20f1 | 2010-01-30 19:55:27 -0500 | [diff] [blame] | 209 | p += scnprintf(p, sizeof(buf) + buf - p, "next dialog_token: %#02x\n", |
Johannes Berg | 386aa23 | 2009-06-17 17:28:45 +0200 | [diff] [blame] | 210 | sta->ampdu_mlme.dialog_token_allocator + 1); |
Pavel Roskin | e0b20f1 | 2010-01-30 19:55:27 -0500 | [diff] [blame] | 211 | p += scnprintf(p, sizeof(buf) + buf - p, |
Johannes Berg | 14b058b | 2014-08-05 09:34:05 +0200 | [diff] [blame] | 212 | "TID\t\tRX\tDTKN\tSSN\t\tTX\tDTKN\tpending\n"); |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 213 | |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 214 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { |
Johannes Berg | b473b8f | 2016-10-18 23:12:09 +0300 | [diff] [blame] | 215 | bool tid_rx_valid; |
| 216 | |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 217 | tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[i]); |
| 218 | tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[i]); |
Johannes Berg | b473b8f | 2016-10-18 23:12:09 +0300 | [diff] [blame] | 219 | tid_rx_valid = test_bit(i, sta->ampdu_mlme.agg_session_valid); |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 220 | |
| 221 | p += scnprintf(p, sizeof(buf) + buf - p, "%02d", i); |
Johannes Berg | b473b8f | 2016-10-18 23:12:09 +0300 | [diff] [blame] | 222 | p += scnprintf(p, sizeof(buf) + buf - p, "\t\t%x", |
| 223 | tid_rx_valid); |
Pavel Roskin | e0b20f1 | 2010-01-30 19:55:27 -0500 | [diff] [blame] | 224 | p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.2x", |
Johannes Berg | b473b8f | 2016-10-18 23:12:09 +0300 | [diff] [blame] | 225 | tid_rx_valid ? |
| 226 | sta->ampdu_mlme.tid_rx_token[i] : 0); |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 227 | p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.3x", |
| 228 | tid_rx ? tid_rx->ssn : 0); |
| 229 | |
| 230 | p += scnprintf(p, sizeof(buf) + buf - p, "\t\t%x", !!tid_tx); |
| 231 | p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.2x", |
| 232 | tid_tx ? tid_tx->dialog_token : 0); |
Pavel Roskin | e0b20f1 | 2010-01-30 19:55:27 -0500 | [diff] [blame] | 233 | p += scnprintf(p, sizeof(buf) + buf - p, "\t%03d", |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 234 | tid_tx ? skb_queue_len(&tid_tx->pending) : 0); |
Pavel Roskin | e0b20f1 | 2010-01-30 19:55:27 -0500 | [diff] [blame] | 235 | p += scnprintf(p, sizeof(buf) + buf - p, "\n"); |
Johannes Berg | 386aa23 | 2009-06-17 17:28:45 +0200 | [diff] [blame] | 236 | } |
Johannes Berg | dd31857 | 2010-11-29 11:09:16 +0100 | [diff] [blame] | 237 | rcu_read_unlock(); |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 238 | |
| 239 | return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 240 | } |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 241 | |
| 242 | static ssize_t sta_agg_status_write(struct file *file, const char __user *userbuf, |
| 243 | size_t count, loff_t *ppos) |
| 244 | { |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 245 | char _buf[25] = {}, *buf = _buf; |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 246 | struct sta_info *sta = file->private_data; |
| 247 | bool start, tx; |
| 248 | unsigned long tid; |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 249 | char *pos; |
| 250 | int ret, timeout = 5000; |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 251 | |
| 252 | if (count > sizeof(_buf)) |
| 253 | return -EINVAL; |
| 254 | |
| 255 | if (copy_from_user(buf, userbuf, count)) |
| 256 | return -EFAULT; |
| 257 | |
| 258 | buf[sizeof(_buf) - 1] = '\0'; |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 259 | pos = buf; |
| 260 | buf = strsep(&pos, " "); |
| 261 | if (!buf) |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 262 | return -EINVAL; |
| 263 | |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 264 | if (!strcmp(buf, "tx")) |
| 265 | tx = true; |
| 266 | else if (!strcmp(buf, "rx")) |
| 267 | tx = false; |
| 268 | else |
| 269 | return -EINVAL; |
| 270 | |
| 271 | buf = strsep(&pos, " "); |
| 272 | if (!buf) |
| 273 | return -EINVAL; |
| 274 | if (!strcmp(buf, "start")) { |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 275 | start = true; |
| 276 | if (!tx) |
| 277 | return -EINVAL; |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 278 | } else if (!strcmp(buf, "stop")) { |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 279 | start = false; |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 280 | } else { |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 281 | return -EINVAL; |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | buf = strsep(&pos, " "); |
| 285 | if (!buf) |
| 286 | return -EINVAL; |
| 287 | if (sscanf(buf, "timeout=%d", &timeout) == 1) { |
| 288 | buf = strsep(&pos, " "); |
| 289 | if (!buf || !tx || !start) |
| 290 | return -EINVAL; |
| 291 | } |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 292 | |
Abhijit Pawar | 4b5511e | 2012-12-09 23:12:28 +0000 | [diff] [blame] | 293 | ret = kstrtoul(buf, 0, &tid); |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 294 | if (ret || tid >= IEEE80211_NUM_TIDS) |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 295 | return -EINVAL; |
| 296 | |
| 297 | if (tx) { |
| 298 | if (start) |
Sara Sharon | 1e0bbeb | 2016-03-09 13:27:09 +0200 | [diff] [blame] | 299 | ret = ieee80211_start_tx_ba_session(&sta->sta, tid, |
| 300 | timeout); |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 301 | else |
Johannes Berg | 6a8579d | 2010-05-27 14:41:07 +0200 | [diff] [blame] | 302 | ret = ieee80211_stop_tx_ba_session(&sta->sta, tid); |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 303 | } else { |
Johannes Berg | 53f73c0 | 2010-10-05 19:37:40 +0200 | [diff] [blame] | 304 | __ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT, |
| 305 | 3, true); |
Johannes Berg | a75b436 | 2010-05-01 18:53:51 +0200 | [diff] [blame] | 306 | ret = 0; |
| 307 | } |
| 308 | |
| 309 | return ret ?: count; |
| 310 | } |
| 311 | STA_OPS_RW(agg_status); |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 312 | |
Johannes Berg | 64491f0 | 2009-11-19 14:26:11 +0100 | [diff] [blame] | 313 | static ssize_t sta_ht_capa_read(struct file *file, char __user *userbuf, |
| 314 | size_t count, loff_t *ppos) |
| 315 | { |
Luis R. Rodriguez | 7db94e2 | 2009-12-07 14:54:45 -0500 | [diff] [blame] | 316 | #define PRINT_HT_CAP(_cond, _str) \ |
| 317 | do { \ |
| 318 | if (_cond) \ |
| 319 | p += scnprintf(p, sizeof(buf)+buf-p, "\t" _str "\n"); \ |
| 320 | } while (0) |
Pavel Roskin | 4c82bf8 | 2010-01-30 19:55:09 -0500 | [diff] [blame] | 321 | char buf[512], *p = buf; |
Johannes Berg | 64491f0 | 2009-11-19 14:26:11 +0100 | [diff] [blame] | 322 | int i; |
| 323 | struct sta_info *sta = file->private_data; |
| 324 | struct ieee80211_sta_ht_cap *htc = &sta->sta.ht_cap; |
| 325 | |
| 326 | p += scnprintf(p, sizeof(buf) + buf - p, "ht %ssupported\n", |
| 327 | htc->ht_supported ? "" : "not "); |
| 328 | if (htc->ht_supported) { |
Luis R. Rodriguez | cb136f5 | 2009-12-07 14:01:28 -0500 | [diff] [blame] | 329 | p += scnprintf(p, sizeof(buf)+buf-p, "cap: %#.4x\n", htc->cap); |
Luis R. Rodriguez | 7db94e2 | 2009-12-07 14:54:45 -0500 | [diff] [blame] | 330 | |
Luis R. Rodriguez | c15cf5f | 2010-04-08 16:08:46 -0400 | [diff] [blame] | 331 | PRINT_HT_CAP((htc->cap & BIT(0)), "RX LDPC"); |
Luis R. Rodriguez | 7db94e2 | 2009-12-07 14:54:45 -0500 | [diff] [blame] | 332 | PRINT_HT_CAP((htc->cap & BIT(1)), "HT20/HT40"); |
| 333 | PRINT_HT_CAP(!(htc->cap & BIT(1)), "HT20"); |
| 334 | |
| 335 | PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 0, "Static SM Power Save"); |
| 336 | PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 1, "Dynamic SM Power Save"); |
| 337 | PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 3, "SM Power Save disabled"); |
| 338 | |
| 339 | PRINT_HT_CAP((htc->cap & BIT(4)), "RX Greenfield"); |
| 340 | PRINT_HT_CAP((htc->cap & BIT(5)), "RX HT20 SGI"); |
| 341 | PRINT_HT_CAP((htc->cap & BIT(6)), "RX HT40 SGI"); |
| 342 | PRINT_HT_CAP((htc->cap & BIT(7)), "TX STBC"); |
| 343 | |
| 344 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 0, "No RX STBC"); |
| 345 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 1, "RX STBC 1-stream"); |
| 346 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 2, "RX STBC 2-streams"); |
| 347 | PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 3, "RX STBC 3-streams"); |
| 348 | |
| 349 | PRINT_HT_CAP((htc->cap & BIT(10)), "HT Delayed Block Ack"); |
| 350 | |
Luis R. Rodriguez | 7db94e2 | 2009-12-07 14:54:45 -0500 | [diff] [blame] | 351 | PRINT_HT_CAP(!(htc->cap & BIT(11)), "Max AMSDU length: " |
Ben Greear | 904603f | 2011-11-17 14:53:36 -0800 | [diff] [blame] | 352 | "3839 bytes"); |
| 353 | PRINT_HT_CAP((htc->cap & BIT(11)), "Max AMSDU length: " |
Luis R. Rodriguez | 7db94e2 | 2009-12-07 14:54:45 -0500 | [diff] [blame] | 354 | "7935 bytes"); |
| 355 | |
| 356 | /* |
| 357 | * For beacons and probe response this would mean the BSS |
| 358 | * does or does not allow the usage of DSSS/CCK HT40. |
| 359 | * Otherwise it means the STA does or does not use |
| 360 | * DSSS/CCK HT40. |
| 361 | */ |
| 362 | PRINT_HT_CAP((htc->cap & BIT(12)), "DSSS/CCK HT40"); |
| 363 | PRINT_HT_CAP(!(htc->cap & BIT(12)), "No DSSS/CCK HT40"); |
| 364 | |
| 365 | /* BIT(13) is reserved */ |
| 366 | |
| 367 | PRINT_HT_CAP((htc->cap & BIT(14)), "40 MHz Intolerant"); |
| 368 | |
| 369 | PRINT_HT_CAP((htc->cap & BIT(15)), "L-SIG TXOP protection"); |
| 370 | |
Johannes Berg | 64491f0 | 2009-11-19 14:26:11 +0100 | [diff] [blame] | 371 | p += scnprintf(p, sizeof(buf)+buf-p, "ampdu factor/density: %d/%d\n", |
| 372 | htc->ampdu_factor, htc->ampdu_density); |
| 373 | p += scnprintf(p, sizeof(buf)+buf-p, "MCS mask:"); |
Luis R. Rodriguez | 9da3e06 | 2009-12-07 15:57:50 -0500 | [diff] [blame] | 374 | |
Johannes Berg | 64491f0 | 2009-11-19 14:26:11 +0100 | [diff] [blame] | 375 | for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) |
| 376 | p += scnprintf(p, sizeof(buf)+buf-p, " %.2x", |
| 377 | htc->mcs.rx_mask[i]); |
Luis R. Rodriguez | 9da3e06 | 2009-12-07 15:57:50 -0500 | [diff] [blame] | 378 | p += scnprintf(p, sizeof(buf)+buf-p, "\n"); |
| 379 | |
| 380 | /* If not set this is meaningless */ |
| 381 | if (le16_to_cpu(htc->mcs.rx_highest)) { |
| 382 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 383 | "MCS rx highest: %d Mbps\n", |
| 384 | le16_to_cpu(htc->mcs.rx_highest)); |
| 385 | } |
| 386 | |
Johannes Berg | 64491f0 | 2009-11-19 14:26:11 +0100 | [diff] [blame] | 387 | p += scnprintf(p, sizeof(buf)+buf-p, "MCS tx params: %x\n", |
| 388 | htc->mcs.tx_params); |
| 389 | } |
| 390 | |
| 391 | return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 392 | } |
| 393 | STA_OPS(ht_capa); |
| 394 | |
Johannes Berg | 90fcba6 | 2013-03-01 13:36:24 +0100 | [diff] [blame] | 395 | static ssize_t sta_vht_capa_read(struct file *file, char __user *userbuf, |
| 396 | size_t count, loff_t *ppos) |
| 397 | { |
Ben Greear | 0bb7ed4 | 2016-05-13 11:29:33 -0700 | [diff] [blame] | 398 | char buf[512], *p = buf; |
Johannes Berg | 90fcba6 | 2013-03-01 13:36:24 +0100 | [diff] [blame] | 399 | struct sta_info *sta = file->private_data; |
| 400 | struct ieee80211_sta_vht_cap *vhtc = &sta->sta.vht_cap; |
| 401 | |
| 402 | p += scnprintf(p, sizeof(buf) + buf - p, "VHT %ssupported\n", |
| 403 | vhtc->vht_supported ? "" : "not "); |
| 404 | if (vhtc->vht_supported) { |
Ben Greear | 0bb7ed4 | 2016-05-13 11:29:33 -0700 | [diff] [blame] | 405 | p += scnprintf(p, sizeof(buf) + buf - p, "cap: %#.8x\n", |
| 406 | vhtc->cap); |
| 407 | #define PFLAG(a, b) \ |
| 408 | do { \ |
| 409 | if (vhtc->cap & IEEE80211_VHT_CAP_ ## a) \ |
| 410 | p += scnprintf(p, sizeof(buf) + buf - p, \ |
| 411 | "\t\t%s\n", b); \ |
| 412 | } while (0) |
| 413 | |
| 414 | switch (vhtc->cap & 0x3) { |
| 415 | case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895: |
| 416 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 417 | "\t\tMAX-MPDU-3895\n"); |
| 418 | break; |
| 419 | case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991: |
| 420 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 421 | "\t\tMAX-MPDU-7991\n"); |
| 422 | break; |
| 423 | case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454: |
| 424 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 425 | "\t\tMAX-MPDU-11454\n"); |
| 426 | break; |
| 427 | default: |
| 428 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 429 | "\t\tMAX-MPDU-UNKNOWN\n"); |
Christopher Díaz Riveros | 9cb05f9 | 2018-01-17 16:03:00 -0500 | [diff] [blame] | 430 | } |
Ben Greear | 0bb7ed4 | 2016-05-13 11:29:33 -0700 | [diff] [blame] | 431 | switch (vhtc->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { |
| 432 | case 0: |
| 433 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 434 | "\t\t80Mhz\n"); |
| 435 | break; |
| 436 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: |
| 437 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 438 | "\t\t160Mhz\n"); |
| 439 | break; |
| 440 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ: |
| 441 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 442 | "\t\t80+80Mhz\n"); |
| 443 | break; |
| 444 | default: |
| 445 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 446 | "\t\tUNKNOWN-MHZ: 0x%x\n", |
| 447 | (vhtc->cap >> 2) & 0x3); |
Christopher Díaz Riveros | 9cb05f9 | 2018-01-17 16:03:00 -0500 | [diff] [blame] | 448 | } |
Ben Greear | 0bb7ed4 | 2016-05-13 11:29:33 -0700 | [diff] [blame] | 449 | PFLAG(RXLDPC, "RXLDPC"); |
| 450 | PFLAG(SHORT_GI_80, "SHORT-GI-80"); |
| 451 | PFLAG(SHORT_GI_160, "SHORT-GI-160"); |
| 452 | PFLAG(TXSTBC, "TXSTBC"); |
| 453 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 454 | "\t\tRXSTBC_%d\n", (vhtc->cap >> 8) & 0x7); |
| 455 | PFLAG(SU_BEAMFORMER_CAPABLE, "SU-BEAMFORMER-CAPABLE"); |
| 456 | PFLAG(SU_BEAMFORMEE_CAPABLE, "SU-BEAMFORMEE-CAPABLE"); |
| 457 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 458 | "\t\tBEAMFORMEE-STS: 0x%x\n", |
| 459 | (vhtc->cap & IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK) >> |
| 460 | IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 461 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 462 | "\t\tSOUNDING-DIMENSIONS: 0x%x\n", |
| 463 | (vhtc->cap & IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK) |
| 464 | >> IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 465 | PFLAG(MU_BEAMFORMER_CAPABLE, "MU-BEAMFORMER-CAPABLE"); |
| 466 | PFLAG(MU_BEAMFORMEE_CAPABLE, "MU-BEAMFORMEE-CAPABLE"); |
| 467 | PFLAG(VHT_TXOP_PS, "TXOP-PS"); |
| 468 | PFLAG(HTC_VHT, "HTC-VHT"); |
| 469 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 470 | "\t\tMPDU-LENGTH-EXPONENT: 0x%x\n", |
| 471 | (vhtc->cap & IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK) >> |
| 472 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 473 | PFLAG(VHT_LINK_ADAPTATION_VHT_UNSOL_MFB, |
| 474 | "LINK-ADAPTATION-VHT-UNSOL-MFB"); |
| 475 | p += scnprintf(p, sizeof(buf) + buf - p, |
| 476 | "\t\tLINK-ADAPTATION-VHT-MRQ-MFB: 0x%x\n", |
| 477 | (vhtc->cap & IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB) >> 26); |
| 478 | PFLAG(RX_ANTENNA_PATTERN, "RX-ANTENNA-PATTERN"); |
| 479 | PFLAG(TX_ANTENNA_PATTERN, "TX-ANTENNA-PATTERN"); |
Johannes Berg | 90fcba6 | 2013-03-01 13:36:24 +0100 | [diff] [blame] | 480 | |
| 481 | p += scnprintf(p, sizeof(buf)+buf-p, "RX MCS: %.4x\n", |
| 482 | le16_to_cpu(vhtc->vht_mcs.rx_mcs_map)); |
| 483 | if (vhtc->vht_mcs.rx_highest) |
| 484 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 485 | "MCS RX highest: %d Mbps\n", |
| 486 | le16_to_cpu(vhtc->vht_mcs.rx_highest)); |
| 487 | p += scnprintf(p, sizeof(buf)+buf-p, "TX MCS: %.4x\n", |
| 488 | le16_to_cpu(vhtc->vht_mcs.tx_mcs_map)); |
| 489 | if (vhtc->vht_mcs.tx_highest) |
| 490 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 491 | "MCS TX highest: %d Mbps\n", |
| 492 | le16_to_cpu(vhtc->vht_mcs.tx_highest)); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 493 | #undef PFLAG |
Johannes Berg | 90fcba6 | 2013-03-01 13:36:24 +0100 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 497 | } |
| 498 | STA_OPS(vht_capa); |
| 499 | |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 500 | static ssize_t sta_he_capa_read(struct file *file, char __user *userbuf, |
| 501 | size_t count, loff_t *ppos) |
| 502 | { |
| 503 | char *buf, *p; |
| 504 | size_t buf_sz = PAGE_SIZE; |
| 505 | struct sta_info *sta = file->private_data; |
| 506 | struct ieee80211_sta_he_cap *hec = &sta->sta.he_cap; |
| 507 | struct ieee80211_he_mcs_nss_supp *nss = &hec->he_mcs_nss_supp; |
| 508 | u8 ppe_size; |
| 509 | u8 *cap; |
| 510 | int i; |
| 511 | ssize_t ret; |
| 512 | |
| 513 | buf = kmalloc(buf_sz, GFP_KERNEL); |
| 514 | if (!buf) |
| 515 | return -ENOMEM; |
| 516 | p = buf; |
| 517 | |
| 518 | p += scnprintf(p, buf_sz + buf - p, "HE %ssupported\n", |
| 519 | hec->has_he ? "" : "not "); |
| 520 | if (!hec->has_he) |
| 521 | goto out; |
| 522 | |
| 523 | cap = hec->he_cap_elem.mac_cap_info; |
| 524 | p += scnprintf(p, buf_sz + buf - p, |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 525 | "MAC-CAP: %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x\n", |
| 526 | cap[0], cap[1], cap[2], cap[3], cap[4], cap[5]); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 527 | |
| 528 | #define PRINT(fmt, ...) \ |
| 529 | p += scnprintf(p, buf_sz + buf - p, "\t\t" fmt "\n", \ |
| 530 | ##__VA_ARGS__) |
| 531 | |
| 532 | #define PFLAG(t, n, a, b) \ |
| 533 | do { \ |
| 534 | if (cap[n] & IEEE80211_HE_##t##_CAP##n##_##a) \ |
| 535 | PRINT("%s", b); \ |
| 536 | } while (0) |
| 537 | |
| 538 | #define PFLAG_RANGE(t, i, n, s, m, off, fmt) \ |
| 539 | do { \ |
| 540 | u8 msk = IEEE80211_HE_##t##_CAP##i##_##n##_MASK; \ |
| 541 | u8 idx = ((cap[i] & msk) >> (ffs(msk) - 1)) + off; \ |
| 542 | PRINT(fmt, (s << idx) + (m * idx)); \ |
| 543 | } while (0) |
| 544 | |
| 545 | #define PFLAG_RANGE_DEFAULT(t, i, n, s, m, off, fmt, a, b) \ |
| 546 | do { \ |
| 547 | if (cap[i] == IEEE80211_HE_##t ##_CAP##i##_##n##_##a) { \ |
| 548 | PRINT("%s", b); \ |
| 549 | break; \ |
| 550 | } \ |
| 551 | PFLAG_RANGE(t, i, n, s, m, off, fmt); \ |
| 552 | } while (0) |
| 553 | |
| 554 | PFLAG(MAC, 0, HTC_HE, "HTC-HE"); |
| 555 | PFLAG(MAC, 0, TWT_REQ, "TWT-REQ"); |
| 556 | PFLAG(MAC, 0, TWT_RES, "TWT-RES"); |
| 557 | PFLAG_RANGE_DEFAULT(MAC, 0, DYNAMIC_FRAG, 0, 1, 0, |
| 558 | "DYNAMIC-FRAG-LEVEL-%d", NOT_SUPP, "NOT-SUPP"); |
| 559 | PFLAG_RANGE_DEFAULT(MAC, 0, MAX_NUM_FRAG_MSDU, 1, 0, 0, |
| 560 | "MAX-NUM-FRAG-MSDU-%d", UNLIMITED, "UNLIMITED"); |
| 561 | |
| 562 | PFLAG_RANGE_DEFAULT(MAC, 1, MIN_FRAG_SIZE, 128, 0, -1, |
| 563 | "MIN-FRAG-SIZE-%d", UNLIMITED, "UNLIMITED"); |
| 564 | PFLAG_RANGE_DEFAULT(MAC, 1, TF_MAC_PAD_DUR, 0, 8, 0, |
| 565 | "TF-MAC-PAD-DUR-%dUS", MASK, "UNKNOWN"); |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 566 | PFLAG_RANGE(MAC, 1, MULTI_TID_AGG_RX_QOS, 0, 1, 1, |
| 567 | "MULTI-TID-AGG-RX-QOS-%d"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 568 | |
| 569 | if (cap[0] & IEEE80211_HE_MAC_CAP0_HTC_HE) { |
| 570 | switch (((cap[2] << 1) | (cap[1] >> 7)) & 0x3) { |
| 571 | case 0: |
| 572 | PRINT("LINK-ADAPTATION-NO-FEEDBACK"); |
| 573 | break; |
| 574 | case 1: |
| 575 | PRINT("LINK-ADAPTATION-RESERVED"); |
| 576 | break; |
| 577 | case 2: |
| 578 | PRINT("LINK-ADAPTATION-UNSOLICITED-FEEDBACK"); |
| 579 | break; |
| 580 | case 3: |
| 581 | PRINT("LINK-ADAPTATION-BOTH"); |
| 582 | break; |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | PFLAG(MAC, 2, ALL_ACK, "ALL-ACK"); |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 587 | PFLAG(MAC, 2, TRS, "TRS"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 588 | PFLAG(MAC, 2, BSR, "BSR"); |
| 589 | PFLAG(MAC, 2, BCAST_TWT, "BCAST-TWT"); |
| 590 | PFLAG(MAC, 2, 32BIT_BA_BITMAP, "32BIT-BA-BITMAP"); |
| 591 | PFLAG(MAC, 2, MU_CASCADING, "MU-CASCADING"); |
| 592 | PFLAG(MAC, 2, ACK_EN, "ACK-EN"); |
| 593 | |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 594 | PFLAG(MAC, 3, OMI_CONTROL, "OMI-CONTROL"); |
| 595 | PFLAG(MAC, 3, OFDMA_RA, "OFDMA-RA"); |
| 596 | |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 597 | switch (cap[3] & IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK) { |
| 598 | case IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_USE_VHT: |
| 599 | PRINT("MAX-AMPDU-LEN-EXP-USE-VHT"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 600 | break; |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 601 | case IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_1: |
| 602 | PRINT("MAX-AMPDU-LEN-EXP-VHT-1"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 603 | break; |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 604 | case IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_2: |
| 605 | PRINT("MAX-AMPDU-LEN-EXP-VHT-2"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 606 | break; |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 607 | case IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_RESERVED: |
| 608 | PRINT("MAX-AMPDU-LEN-EXP-RESERVED"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 609 | break; |
| 610 | } |
| 611 | |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 612 | PFLAG(MAC, 3, AMSDU_FRAG, "AMSDU-FRAG"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 613 | PFLAG(MAC, 3, FLEX_TWT_SCHED, "FLEX-TWT-SCHED"); |
| 614 | PFLAG(MAC, 3, RX_CTRL_FRAME_TO_MULTIBSS, "RX-CTRL-FRAME-TO-MULTIBSS"); |
| 615 | |
| 616 | PFLAG(MAC, 4, BSRP_BQRP_A_MPDU_AGG, "BSRP-BQRP-A-MPDU-AGG"); |
| 617 | PFLAG(MAC, 4, QTP, "QTP"); |
| 618 | PFLAG(MAC, 4, BQR, "BQR"); |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 619 | PFLAG(MAC, 4, SRP_RESP, "SRP-RESP"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 620 | PFLAG(MAC, 4, NDP_FB_REP, "NDP-FB-REP"); |
| 621 | PFLAG(MAC, 4, OPS, "OPS"); |
| 622 | PFLAG(MAC, 4, AMDSU_IN_AMPDU, "AMSDU-IN-AMPDU"); |
| 623 | |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 624 | PRINT("MULTI-TID-AGG-TX-QOS-%d", ((cap[5] << 1) | (cap[4] >> 7)) & 0x7); |
| 625 | |
| 626 | PFLAG(MAC, 5, SUBCHAN_SELECVITE_TRANSMISSION, |
| 627 | "SUBCHAN-SELECVITE-TRANSMISSION"); |
| 628 | PFLAG(MAC, 5, UL_2x996_TONE_RU, "UL-2x996-TONE-RU"); |
| 629 | PFLAG(MAC, 5, OM_CTRL_UL_MU_DATA_DIS_RX, "OM-CTRL-UL-MU-DATA-DIS-RX"); |
| 630 | |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 631 | cap = hec->he_cap_elem.phy_cap_info; |
| 632 | p += scnprintf(p, buf_sz + buf - p, |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 633 | "PHY CAP: %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x %#.2x\n", |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 634 | cap[0], cap[1], cap[2], cap[3], cap[4], cap[5], cap[6], |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 635 | cap[7], cap[8], cap[9], cap[10]); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 636 | |
| 637 | PFLAG(PHY, 0, CHANNEL_WIDTH_SET_40MHZ_IN_2G, |
| 638 | "CHANNEL-WIDTH-SET-40MHZ-IN-2G"); |
| 639 | PFLAG(PHY, 0, CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G, |
| 640 | "CHANNEL-WIDTH-SET-40MHZ-80MHZ-IN-5G"); |
| 641 | PFLAG(PHY, 0, CHANNEL_WIDTH_SET_160MHZ_IN_5G, |
| 642 | "CHANNEL-WIDTH-SET-160MHZ-IN-5G"); |
| 643 | PFLAG(PHY, 0, CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G, |
| 644 | "CHANNEL-WIDTH-SET-80PLUS80-MHZ-IN-5G"); |
| 645 | PFLAG(PHY, 0, CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G, |
| 646 | "CHANNEL-WIDTH-SET-RU-MAPPING-IN-2G"); |
| 647 | PFLAG(PHY, 0, CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G, |
| 648 | "CHANNEL-WIDTH-SET-RU-MAPPING-IN-5G"); |
| 649 | |
| 650 | switch (cap[1] & IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK) { |
| 651 | case IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_20MHZ: |
| 652 | PRINT("PREAMBLE-PUNC-RX-80MHZ-ONLY-SECOND-20MHZ"); |
| 653 | break; |
| 654 | case IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_40MHZ: |
| 655 | PRINT("PREAMBLE-PUNC-RX-80MHZ-ONLY-SECOND-40MHZ"); |
| 656 | break; |
| 657 | case IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_20MHZ: |
| 658 | PRINT("PREAMBLE-PUNC-RX-160MHZ-ONLY-SECOND-20MHZ"); |
| 659 | break; |
| 660 | case IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_40MHZ: |
| 661 | PRINT("PREAMBLE-PUNC-RX-160MHZ-ONLY-SECOND-40MHZ"); |
| 662 | break; |
| 663 | } |
| 664 | |
| 665 | PFLAG(PHY, 1, DEVICE_CLASS_A, |
| 666 | "IEEE80211-HE-PHY-CAP1-DEVICE-CLASS-A"); |
| 667 | PFLAG(PHY, 1, LDPC_CODING_IN_PAYLOAD, |
| 668 | "LDPC-CODING-IN-PAYLOAD"); |
| 669 | PFLAG(PHY, 1, HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US, |
| 670 | "HY-CAP1-HE-LTF-AND-GI-FOR-HE-PPDUS-0-8US"); |
| 671 | PRINT("MIDAMBLE-RX-MAX-NSTS-%d", ((cap[2] << 1) | (cap[1] >> 7)) & 0x3); |
| 672 | |
| 673 | PFLAG(PHY, 2, NDP_4x_LTF_AND_3_2US, "NDP-4X-LTF-AND-3-2US"); |
| 674 | PFLAG(PHY, 2, STBC_TX_UNDER_80MHZ, "STBC-TX-UNDER-80MHZ"); |
| 675 | PFLAG(PHY, 2, STBC_RX_UNDER_80MHZ, "STBC-RX-UNDER-80MHZ"); |
| 676 | PFLAG(PHY, 2, DOPPLER_TX, "DOPPLER-TX"); |
| 677 | PFLAG(PHY, 2, DOPPLER_RX, "DOPPLER-RX"); |
| 678 | PFLAG(PHY, 2, UL_MU_FULL_MU_MIMO, "UL-MU-FULL-MU-MIMO"); |
| 679 | PFLAG(PHY, 2, UL_MU_PARTIAL_MU_MIMO, "UL-MU-PARTIAL-MU-MIMO"); |
| 680 | |
| 681 | switch (cap[3] & IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK) { |
| 682 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM: |
| 683 | PRINT("DCM-MAX-CONST-TX-NO-DCM"); |
| 684 | break; |
| 685 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK: |
| 686 | PRINT("DCM-MAX-CONST-TX-BPSK"); |
| 687 | break; |
| 688 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK: |
| 689 | PRINT("DCM-MAX-CONST-TX-QPSK"); |
| 690 | break; |
| 691 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM: |
| 692 | PRINT("DCM-MAX-CONST-TX-16-QAM"); |
| 693 | break; |
| 694 | } |
| 695 | |
| 696 | PFLAG(PHY, 3, DCM_MAX_TX_NSS_1, "DCM-MAX-TX-NSS-1"); |
| 697 | PFLAG(PHY, 3, DCM_MAX_TX_NSS_2, "DCM-MAX-TX-NSS-2"); |
| 698 | |
| 699 | switch (cap[3] & IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK) { |
| 700 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM: |
| 701 | PRINT("DCM-MAX-CONST-RX-NO-DCM"); |
| 702 | break; |
| 703 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK: |
| 704 | PRINT("DCM-MAX-CONST-RX-BPSK"); |
| 705 | break; |
| 706 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK: |
| 707 | PRINT("DCM-MAX-CONST-RX-QPSK"); |
| 708 | break; |
| 709 | case IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM: |
| 710 | PRINT("DCM-MAX-CONST-RX-16-QAM"); |
| 711 | break; |
| 712 | } |
| 713 | |
| 714 | PFLAG(PHY, 3, DCM_MAX_RX_NSS_1, "DCM-MAX-RX-NSS-1"); |
| 715 | PFLAG(PHY, 3, DCM_MAX_RX_NSS_2, "DCM-MAX-RX-NSS-2"); |
| 716 | PFLAG(PHY, 3, RX_HE_MU_PPDU_FROM_NON_AP_STA, |
| 717 | "RX-HE-MU-PPDU-FROM-NON-AP-STA"); |
| 718 | PFLAG(PHY, 3, SU_BEAMFORMER, "SU-BEAMFORMER"); |
| 719 | |
| 720 | PFLAG(PHY, 4, SU_BEAMFORMEE, "SU-BEAMFORMEE"); |
| 721 | PFLAG(PHY, 4, MU_BEAMFORMER, "MU-BEAMFORMER"); |
| 722 | |
| 723 | PFLAG_RANGE(PHY, 4, BEAMFORMEE_MAX_STS_UNDER_80MHZ, 0, 1, 4, |
| 724 | "BEAMFORMEE-MAX-STS-UNDER-%d"); |
| 725 | PFLAG_RANGE(PHY, 4, BEAMFORMEE_MAX_STS_ABOVE_80MHZ, 0, 1, 4, |
| 726 | "BEAMFORMEE-MAX-STS-ABOVE-%d"); |
| 727 | |
| 728 | PFLAG_RANGE(PHY, 5, BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ, 0, 1, 1, |
| 729 | "NUM-SND-DIM-UNDER-80MHZ-%d"); |
| 730 | PFLAG_RANGE(PHY, 5, BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ, 0, 1, 1, |
| 731 | "NUM-SND-DIM-ABOVE-80MHZ-%d"); |
| 732 | PFLAG(PHY, 5, NG16_SU_FEEDBACK, "NG16-SU-FEEDBACK"); |
| 733 | PFLAG(PHY, 5, NG16_MU_FEEDBACK, "NG16-MU-FEEDBACK"); |
| 734 | |
| 735 | PFLAG(PHY, 6, CODEBOOK_SIZE_42_SU, "CODEBOOK-SIZE-42-SU"); |
| 736 | PFLAG(PHY, 6, CODEBOOK_SIZE_75_MU, "CODEBOOK-SIZE-75-MU"); |
| 737 | PFLAG(PHY, 6, TRIG_SU_BEAMFORMER_FB, "TRIG-SU-BEAMFORMER-FB"); |
| 738 | PFLAG(PHY, 6, TRIG_MU_BEAMFORMER_FB, "TRIG-MU-BEAMFORMER-FB"); |
| 739 | PFLAG(PHY, 6, TRIG_CQI_FB, "TRIG-CQI-FB"); |
| 740 | PFLAG(PHY, 6, PARTIAL_BW_EXT_RANGE, "PARTIAL-BW-EXT-RANGE"); |
| 741 | PFLAG(PHY, 6, PARTIAL_BANDWIDTH_DL_MUMIMO, |
| 742 | "PARTIAL-BANDWIDTH-DL-MUMIMO"); |
| 743 | PFLAG(PHY, 6, PPE_THRESHOLD_PRESENT, "PPE-THRESHOLD-PRESENT"); |
| 744 | |
| 745 | PFLAG(PHY, 7, SRP_BASED_SR, "SRP-BASED-SR"); |
| 746 | PFLAG(PHY, 7, POWER_BOOST_FACTOR_AR, "POWER-BOOST-FACTOR-AR"); |
| 747 | PFLAG(PHY, 7, HE_SU_MU_PPDU_4XLTF_AND_08_US_GI, |
| 748 | "HE-SU-MU-PPDU-4XLTF-AND-08-US-GI"); |
| 749 | PFLAG_RANGE(PHY, 7, MAX_NC, 0, 1, 1, "MAX-NC-%d"); |
| 750 | PFLAG(PHY, 7, STBC_TX_ABOVE_80MHZ, "STBC-TX-ABOVE-80MHZ"); |
| 751 | PFLAG(PHY, 7, STBC_RX_ABOVE_80MHZ, "STBC-RX-ABOVE-80MHZ"); |
| 752 | |
| 753 | PFLAG(PHY, 8, HE_ER_SU_PPDU_4XLTF_AND_08_US_GI, |
| 754 | "HE-ER-SU-PPDU-4XLTF-AND-08-US-GI"); |
| 755 | PFLAG(PHY, 8, 20MHZ_IN_40MHZ_HE_PPDU_IN_2G, |
| 756 | "20MHZ-IN-40MHZ-HE-PPDU-IN-2G"); |
| 757 | PFLAG(PHY, 8, 20MHZ_IN_160MHZ_HE_PPDU, "20MHZ-IN-160MHZ-HE-PPDU"); |
| 758 | PFLAG(PHY, 8, 80MHZ_IN_160MHZ_HE_PPDU, "80MHZ-IN-160MHZ-HE-PPDU"); |
| 759 | PFLAG(PHY, 8, HE_ER_SU_1XLTF_AND_08_US_GI, |
| 760 | "HE-ER-SU-1XLTF-AND-08-US-GI"); |
Shaul Triebitz | add7453 | 2018-09-05 08:06:08 +0300 | [diff] [blame^] | 761 | PFLAG(PHY, 8, MIDAMBLE_RX_TX_2X_AND_1XLTF, |
| 762 | "MIDAMBLE-RX-TX-2X-AND-1XLTF"); |
| 763 | |
| 764 | switch (cap[8] & IEEE80211_HE_PHY_CAP8_DCM_MAX_BW_MASK) { |
| 765 | case IEEE80211_HE_PHY_CAP8_DCM_MAX_BW_20MHZ: |
| 766 | PRINT("DDCM-MAX-BW-20MHZ"); |
| 767 | break; |
| 768 | case IEEE80211_HE_PHY_CAP8_DCM_MAX_BW_40MHZ: |
| 769 | PRINT("DCM-MAX-BW-40MHZ"); |
| 770 | break; |
| 771 | case IEEE80211_HE_PHY_CAP8_DCM_MAX_BW_80MHZ: |
| 772 | PRINT("DCM-MAX-BW-80MHZ"); |
| 773 | break; |
| 774 | case IEEE80211_HE_PHY_CAP8_DCM_MAX_BW_160_OR_80P80_MHZ: |
| 775 | PRINT("DCM-MAX-BW-160-OR-80P80-MHZ"); |
| 776 | break; |
| 777 | } |
| 778 | |
| 779 | PFLAG(PHY, 9, LONGER_THAN_16_SIGB_OFDM_SYM, |
| 780 | "LONGER-THAN-16-SIGB-OFDM-SYM"); |
| 781 | PFLAG(PHY, 9, NON_TRIGGERED_CQI_FEEDBACK, |
| 782 | "NON-TRIGGERED-CQI-FEEDBACK"); |
| 783 | PFLAG(PHY, 9, TX_1024_QAM_LESS_THAN_242_TONE_RU, |
| 784 | "TX-1024-QAM-LESS-THAN-242-TONE-RU"); |
| 785 | PFLAG(PHY, 9, RX_1024_QAM_LESS_THAN_242_TONE_RU, |
| 786 | "RX-1024-QAM-LESS-THAN-242-TONE-RU"); |
| 787 | PFLAG(PHY, 9, RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB, |
| 788 | "RX-FULL-BW-SU-USING-MU-WITH-COMP-SIGB"); |
| 789 | PFLAG(PHY, 9, RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB, |
| 790 | "RX-FULL-BW-SU-USING-MU-WITH-NON-COMP-SIGB"); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 791 | |
| 792 | #undef PFLAG_RANGE_DEFAULT |
| 793 | #undef PFLAG_RANGE |
| 794 | #undef PFLAG |
| 795 | |
| 796 | #define PRINT_NSS_SUPP(f, n) \ |
| 797 | do { \ |
| 798 | int i; \ |
| 799 | u16 v = le16_to_cpu(nss->f); \ |
| 800 | p += scnprintf(p, buf_sz + buf - p, n ": %#.4x\n", v); \ |
| 801 | for (i = 0; i < 8; i += 2) { \ |
| 802 | switch ((v >> i) & 0x3) { \ |
| 803 | case 0: \ |
| 804 | PRINT(n "-%d-SUPPORT-0-7", i / 2); \ |
| 805 | break; \ |
| 806 | case 1: \ |
| 807 | PRINT(n "-%d-SUPPORT-0-9", i / 2); \ |
| 808 | break; \ |
| 809 | case 2: \ |
| 810 | PRINT(n "-%d-SUPPORT-0-11", i / 2); \ |
| 811 | break; \ |
| 812 | case 3: \ |
| 813 | PRINT(n "-%d-NOT-SUPPORTED", i / 2); \ |
| 814 | break; \ |
| 815 | } \ |
| 816 | } \ |
| 817 | } while (0) |
| 818 | |
| 819 | PRINT_NSS_SUPP(rx_mcs_80, "RX-MCS-80"); |
| 820 | PRINT_NSS_SUPP(tx_mcs_80, "TX-MCS-80"); |
| 821 | |
| 822 | if (cap[0] & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G) { |
| 823 | PRINT_NSS_SUPP(rx_mcs_160, "RX-MCS-160"); |
| 824 | PRINT_NSS_SUPP(tx_mcs_160, "TX-MCS-160"); |
| 825 | } |
| 826 | |
| 827 | if (cap[0] & |
| 828 | IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G) { |
| 829 | PRINT_NSS_SUPP(rx_mcs_80p80, "RX-MCS-80P80"); |
| 830 | PRINT_NSS_SUPP(tx_mcs_80p80, "TX-MCS-80P80"); |
| 831 | } |
| 832 | |
| 833 | #undef PRINT_NSS_SUPP |
| 834 | #undef PRINT |
| 835 | |
| 836 | if (!(cap[6] & IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT)) |
| 837 | goto out; |
| 838 | |
| 839 | p += scnprintf(p, buf_sz + buf - p, "PPE-THRESHOLDS: %#.2x", |
| 840 | hec->ppe_thres[0]); |
| 841 | |
| 842 | ppe_size = ieee80211_he_ppe_size(hec->ppe_thres[0], cap); |
| 843 | for (i = 1; i < ppe_size; i++) { |
| 844 | p += scnprintf(p, buf_sz + buf - p, " %#.2x", |
| 845 | hec->ppe_thres[i]); |
| 846 | } |
| 847 | p += scnprintf(p, buf_sz + buf - p, "\n"); |
| 848 | |
| 849 | out: |
| 850 | ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 851 | kfree(buf); |
| 852 | return ret; |
| 853 | } |
| 854 | STA_OPS(he_capa); |
Saravana | 1f2e651 | 2012-11-29 19:54:19 +0530 | [diff] [blame] | 855 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 856 | #define DEBUGFS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 857 | debugfs_create_file(#name, 0400, \ |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 858 | sta->debugfs_dir, sta, &sta_ ##name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 859 | |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 860 | #define DEBUGFS_ADD_COUNTER(name, field) \ |
| 861 | if (sizeof(sta->field) == sizeof(u32)) \ |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 862 | debugfs_create_u32(#name, 0400, sta->debugfs_dir, \ |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 863 | (u32 *) &sta->field); \ |
| 864 | else \ |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 865 | debugfs_create_u64(#name, 0400, sta->debugfs_dir, \ |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 866 | (u64 *) &sta->field); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 867 | |
| 868 | void ieee80211_sta_debugfs_add(struct sta_info *sta) |
| 869 | { |
Sujith Manoharan | 77d2ece | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 870 | struct ieee80211_local *local = sta->local; |
| 871 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Ben Greear | 295bafb | 2010-09-22 20:29:01 -0700 | [diff] [blame] | 872 | struct dentry *stations_dir = sta->sdata->debugfs.subdir_stations; |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 873 | u8 mac[3*ETH_ALEN]; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 874 | |
| 875 | if (!stations_dir) |
| 876 | return; |
| 877 | |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 878 | snprintf(mac, sizeof(mac), "%pM", sta->sta.addr); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 879 | |
Johannes Berg | 63044e9 | 2008-10-07 12:04:29 +0200 | [diff] [blame] | 880 | /* |
| 881 | * This might fail due to a race condition: |
| 882 | * When mac80211 unlinks a station, the debugfs entries |
| 883 | * remain, but it is already possible to link a new |
| 884 | * station with the same address which triggers adding |
| 885 | * it to debugfs; therefore, if the old station isn't |
| 886 | * destroyed quickly enough the old station's debugfs |
| 887 | * dir might still be around. |
| 888 | */ |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 889 | sta->debugfs_dir = debugfs_create_dir(mac, stations_dir); |
| 890 | if (!sta->debugfs_dir) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 891 | return; |
| 892 | |
| 893 | DEBUGFS_ADD(flags); |
Johannes Berg | bddb2afc | 2017-02-07 10:40:50 +0100 | [diff] [blame] | 894 | DEBUGFS_ADD(aid); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 895 | DEBUGFS_ADD(num_ps_buf_frames); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 896 | DEBUGFS_ADD(last_seq_ctrl); |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 897 | DEBUGFS_ADD(agg_status); |
Johannes Berg | 64491f0 | 2009-11-19 14:26:11 +0100 | [diff] [blame] | 898 | DEBUGFS_ADD(ht_capa); |
Johannes Berg | 90fcba6 | 2013-03-01 13:36:24 +0100 | [diff] [blame] | 899 | DEBUGFS_ADD(vht_capa); |
Ido Yariv | 80aaa9c | 2018-08-31 11:31:03 +0300 | [diff] [blame] | 900 | DEBUGFS_ADD(he_capa); |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 901 | |
Johannes Berg | e5a9f8d | 2015-10-16 17:54:47 +0200 | [diff] [blame] | 902 | DEBUGFS_ADD_COUNTER(rx_duplicates, rx_stats.num_duplicates); |
| 903 | DEBUGFS_ADD_COUNTER(rx_fragments, rx_stats.fragments); |
| 904 | DEBUGFS_ADD_COUNTER(tx_filtered, status_stats.filtered); |
Sujith Manoharan | 77d2ece | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 905 | |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 906 | if (local->ops->wake_tx_queue) |
| 907 | DEBUGFS_ADD(aqm); |
| 908 | |
Johannes Berg | 7cf1f14 | 2013-07-12 10:40:31 +0200 | [diff] [blame] | 909 | if (sizeof(sta->driver_buffered_tids) == sizeof(u32)) |
| 910 | debugfs_create_x32("driver_buffered_tids", 0400, |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 911 | sta->debugfs_dir, |
Johannes Berg | 7cf1f14 | 2013-07-12 10:40:31 +0200 | [diff] [blame] | 912 | (u32 *)&sta->driver_buffered_tids); |
| 913 | else |
| 914 | debugfs_create_x64("driver_buffered_tids", 0400, |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 915 | sta->debugfs_dir, |
Johannes Berg | 7cf1f14 | 2013-07-12 10:40:31 +0200 | [diff] [blame] | 916 | (u64 *)&sta->driver_buffered_tids); |
| 917 | |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 918 | drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs_dir); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | void ieee80211_sta_debugfs_remove(struct sta_info *sta) |
| 922 | { |
Johannes Berg | fc4a25c | 2016-04-05 11:59:05 +0200 | [diff] [blame] | 923 | debugfs_remove_recursive(sta->debugfs_dir); |
| 924 | sta->debugfs_dir = NULL; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 925 | } |