2
0

312-mac80211-minstrel_ht-add-flag-to-indicate-missing-in.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. From: Felix Fietkau <[email protected]>
  2. Date: Wed, 16 Jan 2019 22:32:12 +0100
  3. Subject: [PATCH] mac80211: minstrel_ht: add flag to indicate
  4. missing/inaccurate tx A-MPDU length
  5. Some hardware (e.g. MediaTek MT7603) cannot report A-MPDU length in tx status
  6. information. Add support for a flag to indicate that, to allow minstrel_ht
  7. to use a fixed value in its internal calculation (which gives better results
  8. than just defaulting to 1).
  9. Signed-off-by: Felix Fietkau <[email protected]>
  10. Signed-off-by: Johannes Berg <[email protected]>
  11. ---
  12. --- a/include/net/mac80211.h
  13. +++ b/include/net/mac80211.h
  14. @@ -2131,6 +2131,9 @@ struct ieee80211_txq {
  15. * @IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP: The driver (or firmware) doesn't
  16. * support QoS NDP for AP probing - that's most likely a driver bug.
  17. *
  18. + * @IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN: Driver does not report accurate A-MPDU
  19. + * length in tx status information
  20. + *
  21. * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  22. */
  23. enum ieee80211_hw_flags {
  24. @@ -2176,6 +2179,7 @@ enum ieee80211_hw_flags {
  25. IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
  26. IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
  27. IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP,
  28. + IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN,
  29. /* keep last, obviously */
  30. NUM_IEEE80211_HW_FLAGS
  31. --- a/net/mac80211/debugfs.c
  32. +++ b/net/mac80211/debugfs.c
  33. @@ -214,6 +214,7 @@ static const char *hw_flag_names[] = {
  34. FLAG(SUPPORTS_TDLS_BUFFER_STA),
  35. FLAG(DEAUTH_NEED_MGD_TX_PREP),
  36. FLAG(DOESNT_SUPPORT_QOS_NDP),
  37. + FLAG(TX_STATUS_NO_AMPDU_LEN),
  38. #undef FLAG
  39. };
  40. --- a/net/mac80211/rc80211_minstrel_ht.c
  41. +++ b/net/mac80211/rc80211_minstrel_ht.c
  42. @@ -294,6 +294,15 @@ minstrel_get_ratestats(struct minstrel_h
  43. return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
  44. }
  45. +static unsigned int
  46. +minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi)
  47. +{
  48. + if (!mi->avg_ampdu_len)
  49. + return AVG_AMPDU_SIZE;
  50. +
  51. + return MINSTREL_TRUNC(mi->avg_ampdu_len);
  52. +}
  53. +
  54. /*
  55. * Return current throughput based on the average A-MPDU length, taking into
  56. * account the expected number of retransmissions and their expected length
  57. @@ -309,7 +318,7 @@ minstrel_ht_get_tp_avg(struct minstrel_h
  58. return 0;
  59. if (group != MINSTREL_CCK_GROUP)
  60. - nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
  61. + nsecs = 1000 * mi->overhead / minstrel_ht_avg_ampdu_len(mi);
  62. nsecs += minstrel_mcs_groups[group].duration[rate] <<
  63. minstrel_mcs_groups[group].shift;
  64. @@ -503,8 +512,12 @@ minstrel_ht_update_stats(struct minstrel
  65. u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
  66. if (mi->ampdu_packets > 0) {
  67. - mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
  68. - MINSTREL_FRAC(mi->ampdu_len, mi->ampdu_packets), EWMA_LEVEL);
  69. + if (!ieee80211_hw_check(mp->hw, TX_STATUS_NO_AMPDU_LEN))
  70. + mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
  71. + MINSTREL_FRAC(mi->ampdu_len, mi->ampdu_packets),
  72. + EWMA_LEVEL);
  73. + else
  74. + mi->avg_ampdu_len = 0;
  75. mi->ampdu_len = 0;
  76. mi->ampdu_packets = 0;
  77. }
  78. @@ -709,7 +722,9 @@ minstrel_ht_tx_status(void *priv, struct
  79. mi->ampdu_len += info->status.ampdu_len;
  80. if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
  81. - mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
  82. + int avg_ampdu_len = minstrel_ht_avg_ampdu_len(mi);
  83. +
  84. + mi->sample_wait = 16 + 2 * avg_ampdu_len;
  85. mi->sample_tries = 1;
  86. mi->sample_count--;
  87. }
  88. @@ -777,7 +792,7 @@ minstrel_calc_retransmit(struct minstrel
  89. unsigned int cw = mp->cw_min;
  90. unsigned int ctime = 0;
  91. unsigned int t_slot = 9; /* FIXME */
  92. - unsigned int ampdu_len = MINSTREL_TRUNC(mi->avg_ampdu_len);
  93. + unsigned int ampdu_len = minstrel_ht_avg_ampdu_len(mi);
  94. unsigned int overhead = 0, overhead_rtscts = 0;
  95. mrs = minstrel_get_ratestats(mi, index);
  96. --- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
  97. +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
  98. @@ -163,9 +163,10 @@ minstrel_ht_stats_open(struct inode *ino
  99. "lookaround %d\n",
  100. max(0, (int) mi->total_packets - (int) mi->sample_packets),
  101. mi->sample_packets);
  102. - p += sprintf(p, "Average # of aggregated frames per A-MPDU: %d.%d\n",
  103. - MINSTREL_TRUNC(mi->avg_ampdu_len),
  104. - MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
  105. + if (mi->avg_ampdu_len)
  106. + p += sprintf(p, "Average # of aggregated frames per A-MPDU: %d.%d\n",
  107. + MINSTREL_TRUNC(mi->avg_ampdu_len),
  108. + MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
  109. ms->len = p - ms->buf;
  110. WARN_ON(ms->len + sizeof(*ms) > 32768);