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