aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rc80211_minstrel_ht.c
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2011-11-14 09:28:20 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-11-17 15:43:57 -0500
commita5f69d94d8e239b48299abdd836840b7447866ab (patch)
tree649d879ce4d9203537e5c071fcf60da3270d5355 /net/mac80211/rc80211_minstrel_ht.c
parentb79296beeba470074737a7d5a941f4ddd64863d8 (diff)
mac80211: Get rid of search loop for rate group index
Finding the group index for a specific rate is done by looping through all groups and returning if the correct one is found. This code is called for each tx'ed frame and thus it makes sense to reduce its runtime. Do this by calculating the group index by this formula based on the SGI and HT40 flags as well as the stream number: idx = (HT40 * 2 * MINSTREL_MAX_STREAMS) + (SGI * MINSTREL_MAX_STREAMS) + (streams - 1) Hence, the groups are ordered by th HT40 flag first, then by the SGI flag and afterwards by the number of used streams. This should reduce the runtime of minstrel_ht_get_group_idx considerable. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Acked-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/rc80211_minstrel_ht.c')
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 972244f83c0d..787aa11e6cff 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -36,8 +36,17 @@
36/* Transmit duration for the raw data part of an average sized packet */ 36/* Transmit duration for the raw data part of an average sized packet */
37#define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps))) 37#define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps)))
38 38
39/*
40 * Define group sort order: HT40 -> SGI -> #streams
41 */
42#define GROUP_IDX(_streams, _sgi, _ht40) \
43 MINSTREL_MAX_STREAMS * 2 * _ht40 + \
44 MINSTREL_MAX_STREAMS * _sgi + \
45 _streams - 1
46
39/* MCS rate information for an MCS group */ 47/* MCS rate information for an MCS group */
40#define MCS_GROUP(_streams, _sgi, _ht40) { \ 48#define MCS_GROUP(_streams, _sgi, _ht40) \
49 [GROUP_IDX(_streams, _sgi, _ht40)] = { \
41 .streams = _streams, \ 50 .streams = _streams, \
42 .flags = \ 51 .flags = \
43 (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \ 52 (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
@@ -58,6 +67,9 @@
58 * To enable sufficiently targeted rate sampling, MCS rates are divided into 67 * To enable sufficiently targeted rate sampling, MCS rates are divided into
59 * groups, based on the number of streams and flags (HT40, SGI) that they 68 * groups, based on the number of streams and flags (HT40, SGI) that they
60 * use. 69 * use.
70 *
71 * Sortorder has to be fixed for GROUP_IDX macro to be applicable:
72 * HT40 -> SGI -> #streams
61 */ 73 */
62const struct mcs_group minstrel_mcs_groups[] = { 74const struct mcs_group minstrel_mcs_groups[] = {
63 MCS_GROUP(1, 0, 0), 75 MCS_GROUP(1, 0, 0),
@@ -102,21 +114,9 @@ minstrel_ewma(int old, int new, int weight)
102static int 114static int
103minstrel_ht_get_group_idx(struct ieee80211_tx_rate *rate) 115minstrel_ht_get_group_idx(struct ieee80211_tx_rate *rate)
104{ 116{
105 int streams = (rate->idx / MCS_GROUP_RATES) + 1; 117 return GROUP_IDX((rate->idx / MCS_GROUP_RATES) + 1,
106 u32 flags = IEEE80211_TX_RC_SHORT_GI | IEEE80211_TX_RC_40_MHZ_WIDTH; 118 !!(rate->flags & IEEE80211_TX_RC_SHORT_GI),
107 int i; 119 !!(rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH));
108
109 for (i = 0; i < ARRAY_SIZE(minstrel_mcs_groups); i++) {
110 if (minstrel_mcs_groups[i].streams != streams)
111 continue;
112 if (minstrel_mcs_groups[i].flags != (rate->flags & flags))
113 continue;
114
115 return i;
116 }
117
118 WARN_ON(1);
119 return 0;
120} 120}
121 121
122static inline struct minstrel_rate_stats * 122static inline struct minstrel_rate_stats *