debugfs_sta.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/debugfs.h>
  13. #include <linux/ieee80211.h>
  14. #include "ieee80211_i.h"
  15. #include "debugfs.h"
  16. #include "debugfs_sta.h"
  17. #include "sta_info.h"
  18. #include "driver-ops.h"
  19. /* sta attributtes */
  20. #define STA_READ(name, field, format_string) \
  21. static ssize_t sta_ ##name## _read(struct file *file, \
  22. char __user *userbuf, \
  23. size_t count, loff_t *ppos) \
  24. { \
  25. struct sta_info *sta = file->private_data; \
  26. return mac80211_format_buffer(userbuf, count, ppos, \
  27. format_string, sta->field); \
  28. }
  29. #define STA_READ_D(name, field) STA_READ(name, field, "%d\n")
  30. #define STA_OPS(name) \
  31. static const struct file_operations sta_ ##name## _ops = { \
  32. .read = sta_##name##_read, \
  33. .open = simple_open, \
  34. .llseek = generic_file_llseek, \
  35. }
  36. #define STA_OPS_RW(name) \
  37. static const struct file_operations sta_ ##name## _ops = { \
  38. .read = sta_##name##_read, \
  39. .write = sta_##name##_write, \
  40. .open = simple_open, \
  41. .llseek = generic_file_llseek, \
  42. }
  43. #define STA_FILE(name, field, format) \
  44. STA_READ_##format(name, field) \
  45. STA_OPS(name)
  46. STA_FILE(aid, sta.aid, D);
  47. static const char * const sta_flag_names[] = {
  48. #define FLAG(F) [WLAN_STA_##F] = #F
  49. FLAG(AUTH),
  50. FLAG(ASSOC),
  51. FLAG(PS_STA),
  52. FLAG(AUTHORIZED),
  53. FLAG(SHORT_PREAMBLE),
  54. FLAG(WDS),
  55. FLAG(CLEAR_PS_FILT),
  56. FLAG(MFP),
  57. FLAG(BLOCK_BA),
  58. FLAG(PS_DRIVER),
  59. FLAG(PSPOLL),
  60. FLAG(TDLS_PEER),
  61. FLAG(TDLS_PEER_AUTH),
  62. FLAG(TDLS_INITIATOR),
  63. FLAG(TDLS_CHAN_SWITCH),
  64. FLAG(TDLS_OFF_CHANNEL),
  65. FLAG(TDLS_WIDER_BW),
  66. FLAG(UAPSD),
  67. FLAG(SP),
  68. FLAG(4ADDR_EVENT),
  69. FLAG(INSERTED),
  70. FLAG(RATE_CONTROL),
  71. FLAG(TOFFSET_KNOWN),
  72. FLAG(MPSP_OWNER),
  73. FLAG(MPSP_RECIPIENT),
  74. FLAG(PS_DELIVER),
  75. #undef FLAG
  76. };
  77. static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
  78. size_t count, loff_t *ppos)
  79. {
  80. char buf[16 * NUM_WLAN_STA_FLAGS], *pos = buf;
  81. char *end = buf + sizeof(buf) - 1;
  82. struct sta_info *sta = file->private_data;
  83. unsigned int flg;
  84. BUILD_BUG_ON(ARRAY_SIZE(sta_flag_names) != NUM_WLAN_STA_FLAGS);
  85. for (flg = 0; flg < NUM_WLAN_STA_FLAGS; flg++) {
  86. if (test_sta_flag(sta, flg))
  87. pos += scnprintf(pos, end - pos, "%s\n",
  88. sta_flag_names[flg]);
  89. }
  90. return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
  91. }
  92. STA_OPS(flags);
  93. static ssize_t sta_num_ps_buf_frames_read(struct file *file,
  94. char __user *userbuf,
  95. size_t count, loff_t *ppos)
  96. {
  97. struct sta_info *sta = file->private_data;
  98. char buf[17*IEEE80211_NUM_ACS], *p = buf;
  99. int ac;
  100. for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
  101. p += scnprintf(p, sizeof(buf)+buf-p, "AC%d: %d\n", ac,
  102. skb_queue_len(&sta->ps_tx_buf[ac]) +
  103. skb_queue_len(&sta->tx_filtered[ac]));
  104. return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
  105. }
  106. STA_OPS(num_ps_buf_frames);
  107. static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf,
  108. size_t count, loff_t *ppos)
  109. {
  110. char buf[15*IEEE80211_NUM_TIDS], *p = buf;
  111. int i;
  112. struct sta_info *sta = file->private_data;
  113. for (i = 0; i < IEEE80211_NUM_TIDS; i++)
  114. p += scnprintf(p, sizeof(buf)+buf-p, "%x ",
  115. le16_to_cpu(sta->last_seq_ctrl[i]));
  116. p += scnprintf(p, sizeof(buf)+buf-p, "\n");
  117. return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
  118. }
  119. STA_OPS(last_seq_ctrl);
  120. #define AQM_TXQ_ENTRY_LEN 130
  121. static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
  122. size_t count, loff_t *ppos)
  123. {
  124. struct sta_info *sta = file->private_data;
  125. struct ieee80211_local *local = sta->local;
  126. size_t bufsz = AQM_TXQ_ENTRY_LEN*(IEEE80211_NUM_TIDS+1);
  127. char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
  128. struct txq_info *txqi;
  129. ssize_t rv;
  130. int i;
  131. if (!buf)
  132. return -ENOMEM;
  133. spin_lock_bh(&local->fq.lock);
  134. rcu_read_lock();
  135. p += scnprintf(p,
  136. bufsz+buf-p,
  137. "target %uus interval %uus ecn %s\n",
  138. codel_time_to_us(sta->cparams.target),
  139. codel_time_to_us(sta->cparams.interval),
  140. sta->cparams.ecn ? "yes" : "no");
  141. p += scnprintf(p,
  142. bufsz+buf-p,
  143. "tid ac backlog-bytes backlog-packets new-flows drops marks overlimit collisions tx-bytes tx-packets flags\n");
  144. for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
  145. txqi = to_txq_info(sta->sta.txq[i]);
  146. p += scnprintf(p, bufsz+buf-p,
  147. "%d %d %u %u %u %u %u %u %u %u %u 0x%lx(%s%s%s)\n",
  148. txqi->txq.tid,
  149. txqi->txq.ac,
  150. txqi->tin.backlog_bytes,
  151. txqi->tin.backlog_packets,
  152. txqi->tin.flows,
  153. txqi->cstats.drop_count,
  154. txqi->cstats.ecn_mark,
  155. txqi->tin.overlimit,
  156. txqi->tin.collisions,
  157. txqi->tin.tx_bytes,
  158. txqi->tin.tx_packets,
  159. txqi->flags,
  160. txqi->flags & (1<<IEEE80211_TXQ_STOP) ? "STOP" : "RUN",
  161. txqi->flags & (1<<IEEE80211_TXQ_AMPDU) ? " AMPDU" : "",
  162. txqi->flags & (1<<IEEE80211_TXQ_NO_AMSDU) ? " NO-AMSDU" : "");
  163. }
  164. rcu_read_unlock();
  165. spin_unlock_bh(&local->fq.lock);
  166. rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
  167. kfree(buf);
  168. return rv;
  169. }
  170. STA_OPS(aqm);
  171. static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
  172. size_t count, loff_t *ppos)
  173. {
  174. char buf[71 + IEEE80211_NUM_TIDS * 40], *p = buf;
  175. int i;
  176. struct sta_info *sta = file->private_data;
  177. struct tid_ampdu_rx *tid_rx;
  178. struct tid_ampdu_tx *tid_tx;
  179. rcu_read_lock();
  180. p += scnprintf(p, sizeof(buf) + buf - p, "next dialog_token: %#02x\n",
  181. sta->ampdu_mlme.dialog_token_allocator + 1);
  182. p += scnprintf(p, sizeof(buf) + buf - p,
  183. "TID\t\tRX\tDTKN\tSSN\t\tTX\tDTKN\tpending\n");
  184. for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
  185. bool tid_rx_valid;
  186. tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[i]);
  187. tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[i]);
  188. tid_rx_valid = test_bit(i, sta->ampdu_mlme.agg_session_valid);
  189. p += scnprintf(p, sizeof(buf) + buf - p, "%02d", i);
  190. p += scnprintf(p, sizeof(buf) + buf - p, "\t\t%x",
  191. tid_rx_valid);
  192. p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.2x",
  193. tid_rx_valid ?
  194. sta->ampdu_mlme.tid_rx_token[i] : 0);
  195. p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.3x",
  196. tid_rx ? tid_rx->ssn : 0);
  197. p += scnprintf(p, sizeof(buf) + buf - p, "\t\t%x", !!tid_tx);
  198. p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.2x",
  199. tid_tx ? tid_tx->dialog_token : 0);
  200. p += scnprintf(p, sizeof(buf) + buf - p, "\t%03d",
  201. tid_tx ? skb_queue_len(&tid_tx->pending) : 0);
  202. p += scnprintf(p, sizeof(buf) + buf - p, "\n");
  203. }
  204. rcu_read_unlock();
  205. return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
  206. }
  207. static ssize_t sta_agg_status_write(struct file *file, const char __user *userbuf,
  208. size_t count, loff_t *ppos)
  209. {
  210. char _buf[25] = {}, *buf = _buf;
  211. struct sta_info *sta = file->private_data;
  212. bool start, tx;
  213. unsigned long tid;
  214. char *pos;
  215. int ret, timeout = 5000;
  216. if (count > sizeof(_buf))
  217. return -EINVAL;
  218. if (copy_from_user(buf, userbuf, count))
  219. return -EFAULT;
  220. buf[sizeof(_buf) - 1] = '\0';
  221. pos = buf;
  222. buf = strsep(&pos, " ");
  223. if (!buf)
  224. return -EINVAL;
  225. if (!strcmp(buf, "tx"))
  226. tx = true;
  227. else if (!strcmp(buf, "rx"))
  228. tx = false;
  229. else
  230. return -EINVAL;
  231. buf = strsep(&pos, " ");
  232. if (!buf)
  233. return -EINVAL;
  234. if (!strcmp(buf, "start")) {
  235. start = true;
  236. if (!tx)
  237. return -EINVAL;
  238. } else if (!strcmp(buf, "stop")) {
  239. start = false;
  240. } else {
  241. return -EINVAL;
  242. }
  243. buf = strsep(&pos, " ");
  244. if (!buf)
  245. return -EINVAL;
  246. if (sscanf(buf, "timeout=%d", &timeout) == 1) {
  247. buf = strsep(&pos, " ");
  248. if (!buf || !tx || !start)
  249. return -EINVAL;
  250. }
  251. ret = kstrtoul(buf, 0, &tid);
  252. if (ret || tid >= IEEE80211_NUM_TIDS)
  253. return -EINVAL;
  254. if (tx) {
  255. if (start)
  256. ret = ieee80211_start_tx_ba_session(&sta->sta, tid,
  257. timeout);
  258. else
  259. ret = ieee80211_stop_tx_ba_session(&sta->sta, tid);
  260. } else {
  261. __ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT,
  262. 3, true);
  263. ret = 0;
  264. }
  265. return ret ?: count;
  266. }
  267. STA_OPS_RW(agg_status);
  268. static ssize_t sta_ht_capa_read(struct file *file, char __user *userbuf,
  269. size_t count, loff_t *ppos)
  270. {
  271. #define PRINT_HT_CAP(_cond, _str) \
  272. do { \
  273. if (_cond) \
  274. p += scnprintf(p, sizeof(buf)+buf-p, "\t" _str "\n"); \
  275. } while (0)
  276. char buf[512], *p = buf;
  277. int i;
  278. struct sta_info *sta = file->private_data;
  279. struct ieee80211_sta_ht_cap *htc = &sta->sta.ht_cap;
  280. p += scnprintf(p, sizeof(buf) + buf - p, "ht %ssupported\n",
  281. htc->ht_supported ? "" : "not ");
  282. if (htc->ht_supported) {
  283. p += scnprintf(p, sizeof(buf)+buf-p, "cap: %#.4x\n", htc->cap);
  284. PRINT_HT_CAP((htc->cap & BIT(0)), "RX LDPC");
  285. PRINT_HT_CAP((htc->cap & BIT(1)), "HT20/HT40");
  286. PRINT_HT_CAP(!(htc->cap & BIT(1)), "HT20");
  287. PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 0, "Static SM Power Save");
  288. PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 1, "Dynamic SM Power Save");
  289. PRINT_HT_CAP(((htc->cap >> 2) & 0x3) == 3, "SM Power Save disabled");
  290. PRINT_HT_CAP((htc->cap & BIT(4)), "RX Greenfield");
  291. PRINT_HT_CAP((htc->cap & BIT(5)), "RX HT20 SGI");
  292. PRINT_HT_CAP((htc->cap & BIT(6)), "RX HT40 SGI");
  293. PRINT_HT_CAP((htc->cap & BIT(7)), "TX STBC");
  294. PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 0, "No RX STBC");
  295. PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 1, "RX STBC 1-stream");
  296. PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 2, "RX STBC 2-streams");
  297. PRINT_HT_CAP(((htc->cap >> 8) & 0x3) == 3, "RX STBC 3-streams");
  298. PRINT_HT_CAP((htc->cap & BIT(10)), "HT Delayed Block Ack");
  299. PRINT_HT_CAP(!(htc->cap & BIT(11)), "Max AMSDU length: "
  300. "3839 bytes");
  301. PRINT_HT_CAP((htc->cap & BIT(11)), "Max AMSDU length: "
  302. "7935 bytes");
  303. /*
  304. * For beacons and probe response this would mean the BSS
  305. * does or does not allow the usage of DSSS/CCK HT40.
  306. * Otherwise it means the STA does or does not use
  307. * DSSS/CCK HT40.
  308. */
  309. PRINT_HT_CAP((htc->cap & BIT(12)), "DSSS/CCK HT40");
  310. PRINT_HT_CAP(!(htc->cap & BIT(12)), "No DSSS/CCK HT40");
  311. /* BIT(13) is reserved */
  312. PRINT_HT_CAP((htc->cap & BIT(14)), "40 MHz Intolerant");
  313. PRINT_HT_CAP((htc->cap & BIT(15)), "L-SIG TXOP protection");
  314. p += scnprintf(p, sizeof(buf)+buf-p, "ampdu factor/density: %d/%d\n",
  315. htc->ampdu_factor, htc->ampdu_density);
  316. p += scnprintf(p, sizeof(buf)+buf-p, "MCS mask:");
  317. for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
  318. p += scnprintf(p, sizeof(buf)+buf-p, " %.2x",
  319. htc->mcs.rx_mask[i]);
  320. p += scnprintf(p, sizeof(buf)+buf-p, "\n");
  321. /* If not set this is meaningless */
  322. if (le16_to_cpu(htc->mcs.rx_highest)) {
  323. p += scnprintf(p, sizeof(buf)+buf-p,
  324. "MCS rx highest: %d Mbps\n",
  325. le16_to_cpu(htc->mcs.rx_highest));
  326. }
  327. p += scnprintf(p, sizeof(buf)+buf-p, "MCS tx params: %x\n",
  328. htc->mcs.tx_params);
  329. }
  330. return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
  331. }
  332. STA_OPS(ht_capa);
  333. static ssize_t sta_vht_capa_read(struct file *file, char __user *userbuf,
  334. size_t count, loff_t *ppos)
  335. {
  336. char buf[512], *p = buf;
  337. struct sta_info *sta = file->private_data;
  338. struct ieee80211_sta_vht_cap *vhtc = &sta->sta.vht_cap;
  339. p += scnprintf(p, sizeof(buf) + buf - p, "VHT %ssupported\n",
  340. vhtc->vht_supported ? "" : "not ");
  341. if (vhtc->vht_supported) {
  342. p += scnprintf(p, sizeof(buf) + buf - p, "cap: %#.8x\n",
  343. vhtc->cap);
  344. #define PFLAG(a, b) \
  345. do { \
  346. if (vhtc->cap & IEEE80211_VHT_CAP_ ## a) \
  347. p += scnprintf(p, sizeof(buf) + buf - p, \
  348. "\t\t%s\n", b); \
  349. } while (0)
  350. switch (vhtc->cap & 0x3) {
  351. case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895:
  352. p += scnprintf(p, sizeof(buf) + buf - p,
  353. "\t\tMAX-MPDU-3895\n");
  354. break;
  355. case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991:
  356. p += scnprintf(p, sizeof(buf) + buf - p,
  357. "\t\tMAX-MPDU-7991\n");
  358. break;
  359. case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454:
  360. p += scnprintf(p, sizeof(buf) + buf - p,
  361. "\t\tMAX-MPDU-11454\n");
  362. break;
  363. default:
  364. p += scnprintf(p, sizeof(buf) + buf - p,
  365. "\t\tMAX-MPDU-UNKNOWN\n");
  366. }
  367. switch (vhtc->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) {
  368. case 0:
  369. p += scnprintf(p, sizeof(buf) + buf - p,
  370. "\t\t80Mhz\n");
  371. break;
  372. case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ:
  373. p += scnprintf(p, sizeof(buf) + buf - p,
  374. "\t\t160Mhz\n");
  375. break;
  376. case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ:
  377. p += scnprintf(p, sizeof(buf) + buf - p,
  378. "\t\t80+80Mhz\n");
  379. break;
  380. default:
  381. p += scnprintf(p, sizeof(buf) + buf - p,
  382. "\t\tUNKNOWN-MHZ: 0x%x\n",
  383. (vhtc->cap >> 2) & 0x3);
  384. }
  385. PFLAG(RXLDPC, "RXLDPC");
  386. PFLAG(SHORT_GI_80, "SHORT-GI-80");
  387. PFLAG(SHORT_GI_160, "SHORT-GI-160");
  388. PFLAG(TXSTBC, "TXSTBC");
  389. p += scnprintf(p, sizeof(buf) + buf - p,
  390. "\t\tRXSTBC_%d\n", (vhtc->cap >> 8) & 0x7);
  391. PFLAG(SU_BEAMFORMER_CAPABLE, "SU-BEAMFORMER-CAPABLE");
  392. PFLAG(SU_BEAMFORMEE_CAPABLE, "SU-BEAMFORMEE-CAPABLE");
  393. p += scnprintf(p, sizeof(buf) + buf - p,
  394. "\t\tBEAMFORMEE-STS: 0x%x\n",
  395. (vhtc->cap & IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK) >>
  396. IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT);
  397. p += scnprintf(p, sizeof(buf) + buf - p,
  398. "\t\tSOUNDING-DIMENSIONS: 0x%x\n",
  399. (vhtc->cap & IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK)
  400. >> IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT);
  401. PFLAG(MU_BEAMFORMER_CAPABLE, "MU-BEAMFORMER-CAPABLE");
  402. PFLAG(MU_BEAMFORMEE_CAPABLE, "MU-BEAMFORMEE-CAPABLE");
  403. PFLAG(VHT_TXOP_PS, "TXOP-PS");
  404. PFLAG(HTC_VHT, "HTC-VHT");
  405. p += scnprintf(p, sizeof(buf) + buf - p,
  406. "\t\tMPDU-LENGTH-EXPONENT: 0x%x\n",
  407. (vhtc->cap & IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK) >>
  408. IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT);
  409. PFLAG(VHT_LINK_ADAPTATION_VHT_UNSOL_MFB,
  410. "LINK-ADAPTATION-VHT-UNSOL-MFB");
  411. p += scnprintf(p, sizeof(buf) + buf - p,
  412. "\t\tLINK-ADAPTATION-VHT-MRQ-MFB: 0x%x\n",
  413. (vhtc->cap & IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB) >> 26);
  414. PFLAG(RX_ANTENNA_PATTERN, "RX-ANTENNA-PATTERN");
  415. PFLAG(TX_ANTENNA_PATTERN, "TX-ANTENNA-PATTERN");
  416. p += scnprintf(p, sizeof(buf)+buf-p, "RX MCS: %.4x\n",
  417. le16_to_cpu(vhtc->vht_mcs.rx_mcs_map));
  418. if (vhtc->vht_mcs.rx_highest)
  419. p += scnprintf(p, sizeof(buf)+buf-p,
  420. "MCS RX highest: %d Mbps\n",
  421. le16_to_cpu(vhtc->vht_mcs.rx_highest));
  422. p += scnprintf(p, sizeof(buf)+buf-p, "TX MCS: %.4x\n",
  423. le16_to_cpu(vhtc->vht_mcs.tx_mcs_map));
  424. if (vhtc->vht_mcs.tx_highest)
  425. p += scnprintf(p, sizeof(buf)+buf-p,
  426. "MCS TX highest: %d Mbps\n",
  427. le16_to_cpu(vhtc->vht_mcs.tx_highest));
  428. }
  429. return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
  430. }
  431. STA_OPS(vht_capa);
  432. #define DEBUGFS_ADD(name) \
  433. debugfs_create_file(#name, 0400, \
  434. sta->debugfs_dir, sta, &sta_ ##name## _ops);
  435. #define DEBUGFS_ADD_COUNTER(name, field) \
  436. if (sizeof(sta->field) == sizeof(u32)) \
  437. debugfs_create_u32(#name, 0400, sta->debugfs_dir, \
  438. (u32 *) &sta->field); \
  439. else \
  440. debugfs_create_u64(#name, 0400, sta->debugfs_dir, \
  441. (u64 *) &sta->field);
  442. void ieee80211_sta_debugfs_add(struct sta_info *sta)
  443. {
  444. struct ieee80211_local *local = sta->local;
  445. struct ieee80211_sub_if_data *sdata = sta->sdata;
  446. struct dentry *stations_dir = sta->sdata->debugfs.subdir_stations;
  447. u8 mac[3*ETH_ALEN];
  448. if (!stations_dir)
  449. return;
  450. snprintf(mac, sizeof(mac), "%pM", sta->sta.addr);
  451. /*
  452. * This might fail due to a race condition:
  453. * When mac80211 unlinks a station, the debugfs entries
  454. * remain, but it is already possible to link a new
  455. * station with the same address which triggers adding
  456. * it to debugfs; therefore, if the old station isn't
  457. * destroyed quickly enough the old station's debugfs
  458. * dir might still be around.
  459. */
  460. sta->debugfs_dir = debugfs_create_dir(mac, stations_dir);
  461. if (!sta->debugfs_dir)
  462. return;
  463. DEBUGFS_ADD(flags);
  464. DEBUGFS_ADD(aid);
  465. DEBUGFS_ADD(num_ps_buf_frames);
  466. DEBUGFS_ADD(last_seq_ctrl);
  467. DEBUGFS_ADD(agg_status);
  468. DEBUGFS_ADD(ht_capa);
  469. DEBUGFS_ADD(vht_capa);
  470. DEBUGFS_ADD_COUNTER(rx_duplicates, rx_stats.num_duplicates);
  471. DEBUGFS_ADD_COUNTER(rx_fragments, rx_stats.fragments);
  472. DEBUGFS_ADD_COUNTER(tx_filtered, status_stats.filtered);
  473. if (local->ops->wake_tx_queue)
  474. DEBUGFS_ADD(aqm);
  475. if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
  476. debugfs_create_x32("driver_buffered_tids", 0400,
  477. sta->debugfs_dir,
  478. (u32 *)&sta->driver_buffered_tids);
  479. else
  480. debugfs_create_x64("driver_buffered_tids", 0400,
  481. sta->debugfs_dir,
  482. (u64 *)&sta->driver_buffered_tids);
  483. drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs_dir);
  484. }
  485. void ieee80211_sta_debugfs_remove(struct sta_info *sta)
  486. {
  487. debugfs_remove_recursive(sta->debugfs_dir);
  488. sta->debugfs_dir = NULL;
  489. }