rc80211_minstrel_ht.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __RC_MINSTREL_HT_H
  9. #define __RC_MINSTREL_HT_H
  10. /*
  11. * The number of streams can be changed to 2 to reduce code
  12. * size and memory footprint.
  13. */
  14. #define MINSTREL_MAX_STREAMS 3
  15. #define MINSTREL_STREAM_GROUPS 4
  16. /* scaled fraction values */
  17. #define MINSTREL_SCALE 16
  18. #define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
  19. #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
  20. #define MCS_GROUP_RATES 8
  21. struct mcs_group {
  22. u32 flags;
  23. unsigned int streams;
  24. unsigned int duration[MCS_GROUP_RATES];
  25. };
  26. extern const struct mcs_group minstrel_mcs_groups[];
  27. struct minstrel_rate_stats {
  28. /* current / last sampling period attempts/success counters */
  29. unsigned int attempts, last_attempts;
  30. unsigned int success, last_success;
  31. /* total attempts/success counters */
  32. u64 att_hist, succ_hist;
  33. /* current throughput */
  34. unsigned int cur_tp;
  35. /* packet delivery probabilities */
  36. unsigned int cur_prob, probability;
  37. /* maximum retry counts */
  38. unsigned int retry_count;
  39. unsigned int retry_count_rtscts;
  40. bool retry_updated;
  41. u8 sample_skipped;
  42. };
  43. struct minstrel_mcs_group_data {
  44. u8 index;
  45. u8 column;
  46. /* bitfield of supported MCS rates of this group */
  47. u8 supported;
  48. /* selected primary rates */
  49. unsigned int max_tp_rate;
  50. unsigned int max_tp_rate2;
  51. unsigned int max_prob_rate;
  52. /* MCS rate statistics */
  53. struct minstrel_rate_stats rates[MCS_GROUP_RATES];
  54. };
  55. struct minstrel_ht_sta {
  56. /* ampdu length (average, per sampling interval) */
  57. unsigned int ampdu_len;
  58. unsigned int ampdu_packets;
  59. /* ampdu length (EWMA) */
  60. unsigned int avg_ampdu_len;
  61. /* best throughput rate */
  62. unsigned int max_tp_rate;
  63. /* second best throughput rate */
  64. unsigned int max_tp_rate2;
  65. /* best probability rate */
  66. unsigned int max_prob_rate;
  67. /* time of last status update */
  68. unsigned long stats_update;
  69. /* overhead time in usec for each frame */
  70. unsigned int overhead;
  71. unsigned int overhead_rtscts;
  72. unsigned int total_packets;
  73. unsigned int sample_packets;
  74. /* tx flags to add for frames for this sta */
  75. u32 tx_flags;
  76. u8 sample_wait;
  77. u8 sample_tries;
  78. u8 sample_count;
  79. u8 sample_slow;
  80. /* current MCS group to be sampled */
  81. u8 sample_group;
  82. /* MCS rate group info and statistics */
  83. struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS];
  84. };
  85. struct minstrel_ht_sta_priv {
  86. union {
  87. struct minstrel_ht_sta ht;
  88. struct minstrel_sta_info legacy;
  89. };
  90. #ifdef CONFIG_MAC80211_DEBUGFS
  91. struct dentry *dbg_stats;
  92. #endif
  93. void *ratelist;
  94. void *sample_table;
  95. bool is_ht;
  96. };
  97. void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
  98. void minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta);
  99. #endif