root/net/mac80211/debugfs_sta.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sta_flags_read
  2. sta_num_ps_buf_frames_read
  3. sta_last_seq_ctrl_read
  4. sta_aqm_read
  5. sta_airtime_read
  6. sta_airtime_write
  7. sta_agg_status_read
  8. sta_agg_status_write
  9. sta_ht_capa_read
  10. sta_vht_capa_read
  11. sta_he_capa_read
  12. ieee80211_sta_debugfs_add
  13. ieee80211_sta_debugfs_remove

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

/* [<][>][^][v][top][bottom][index][help] */