rc80211_minstrel_ht.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. struct minstrel_rate_stats {
  27. /* current / last sampling period attempts/success counters */
  28. unsigned int attempts, last_attempts;
  29. unsigned int success, last_success;
  30. /* total attempts/success counters */
  31. u64 att_hist, succ_hist;
  32. /* current throughput */
  33. unsigned int cur_tp;
  34. /* packet delivery probabilities */
  35. unsigned int cur_prob, probability;
  36. /* maximum retry counts */
  37. unsigned int retry_count;
  38. unsigned int retry_count_rtscts;
  39. bool retry_updated;
  40. u8 sample_skipped;
  41. };
  42. struct minstrel_mcs_group_data {
  43. u8 index;
  44. u8 column;
  45. /* bitfield of supported MCS rates of this group */
  46. u8 supported;
  47. /* selected primary rates */
  48. unsigned int max_tp_rate;
  49. unsigned int max_tp_rate2;
  50. unsigned int max_prob_rate;
  51. /* MCS rate statistics */
  52. struct minstrel_rate_stats rates[MCS_GROUP_RATES];
  53. };
  54. struct minstrel_ht_sta {
  55. /* ampdu length (average, per sampling interval) */
  56. unsigned int ampdu_len;
  57. unsigned int ampdu_packets;
  58. /* ampdu length (EWMA) */
  59. unsigned int avg_ampdu_len;
  60. /* best throughput rate */
  61. unsigned int max_tp_rate;
  62. /* second best throughput rate */
  63. unsigned int max_tp_rate2;
  64. /* best probability rate */
  65. unsigned int max_prob_rate;
  66. /* time of last status update */
  67. unsigned long stats_update;
  68. /* overhead time in usec for each frame */
  69. unsigned int overhead;
  70. unsigned int overhead_rtscts;
  71. unsigned int total_packets;
  72. unsigned int sample_packets;
  73. /* tx flags to add for frames for this sta */
  74. u32 tx_flags;
  75. u8 sample_wait;
  76. u8 sample_tries;
  77. u8 sample_count;
  78. u8 sample_slow;
  79. /* current MCS group to be sampled */
  80. u8 sample_group;
  81. /* MCS rate group info and statistics */
  82. struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS];
  83. };
  84. struct minstrel_ht_sta_priv {
  85. union {
  86. struct minstrel_ht_sta ht;
  87. struct minstrel_sta_info legacy;
  88. };
  89. #ifdef CONFIG_MAC80211_DEBUGFS
  90. struct dentry *dbg_stats;
  91. #endif
  92. void *ratelist;
  93. void *sample_table;
  94. bool is_ht;
  95. };
  96. void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
  97. void minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta);
  98. #endif