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