Fresh pull from upstream
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 334-mac80211-minstrel_ht-move-supported-bitrate-mask-out.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 14 Dec 2016 19:33:23 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: move supported bitrate mask out of
4  group data
5
6 Improves dcache footprint by ensuring that fewer cache lines need to be
7 touched.
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/net/mac80211/rc80211_minstrel_ht.c
13 +++ b/net/mac80211/rc80211_minstrel_ht.c
14 @@ -301,7 +301,7 @@ minstrel_ht_get_stats(struct minstrel_pr
15                                 break;
16  
17                 /* short preamble */
18 -               if (!(mi->groups[group].supported & BIT(idx)))
19 +               if (!(mi->supported[group] & BIT(idx)))
20                         idx += 4;
21         }
22         return &mi->groups[group].rates[idx];
23 @@ -486,7 +486,7 @@ minstrel_ht_prob_rate_reduce_streams(str
24                           MCS_GROUP_RATES].streams;
25         for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
26                 mg = &mi->groups[group];
27 -               if (!mg->supported || group == MINSTREL_CCK_GROUP)
28 +               if (!mi->supported[group] || group == MINSTREL_CCK_GROUP)
29                         continue;
30  
31                 tmp_idx = mg->max_group_prob_rate % MCS_GROUP_RATES;
32 @@ -540,7 +540,7 @@ minstrel_ht_update_stats(struct minstrel
33         for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
34  
35                 mg = &mi->groups[group];
36 -               if (!mg->supported)
37 +               if (!mi->supported[group])
38                         continue;
39  
40                 mi->sample_count++;
41 @@ -550,7 +550,7 @@ minstrel_ht_update_stats(struct minstrel
42                         tmp_group_tp_rate[j] = group;
43  
44                 for (i = 0; i < MCS_GROUP_RATES; i++) {
45 -                       if (!(mg->supported & BIT(i)))
46 +                       if (!(mi->supported[group] & BIT(i)))
47                                 continue;
48  
49                         index = MCS_GROUP_RATES * group + i;
50 @@ -636,7 +636,7 @@ minstrel_set_next_sample_idx(struct mins
51                 mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups);
52                 mg = &mi->groups[mi->sample_group];
53  
54 -               if (!mg->supported)
55 +               if (!mi->supported[mi->sample_group])
56                         continue;
57  
58                 if (++mg->index >= MCS_GROUP_RATES) {
59 @@ -657,7 +657,7 @@ minstrel_downgrade_rate(struct minstrel_
60         while (group > 0) {
61                 group--;
62  
63 -               if (!mi->groups[group].supported)
64 +               if (!mi->supported[group])
65                         continue;
66  
67                 if (minstrel_mcs_groups[group].streams >
68 @@ -994,7 +994,7 @@ minstrel_get_sample_rate(struct minstrel
69         sample_idx = sample_table[mg->column][mg->index];
70         minstrel_set_next_sample_idx(mi);
71  
72 -       if (!(mg->supported & BIT(sample_idx)))
73 +       if (!(mi->supported[sample_group] & BIT(sample_idx)))
74                 return -1;
75  
76         mrs = &mg->rates[sample_idx];
77 @@ -1052,7 +1052,7 @@ static void
78  minstrel_ht_check_cck_shortpreamble(struct minstrel_priv *mp,
79                                     struct minstrel_ht_sta *mi, bool val)
80  {
81 -       u8 supported = mi->groups[MINSTREL_CCK_GROUP].supported;
82 +       u8 supported = mi->supported[MINSTREL_CCK_GROUP];
83  
84         if (!supported || !mi->cck_supported_short)
85                 return;
86 @@ -1061,7 +1061,7 @@ minstrel_ht_check_cck_shortpreamble(stru
87                 return;
88  
89         supported ^= mi->cck_supported_short | (mi->cck_supported_short << 4);
90 -       mi->groups[MINSTREL_CCK_GROUP].supported = supported;
91 +       mi->supported[MINSTREL_CCK_GROUP] = supported;
92  }
93  
94  static void
95 @@ -1154,7 +1154,7 @@ minstrel_ht_update_cck(struct minstrel_p
96                         mi->cck_supported_short |= BIT(i);
97         }
98  
99 -       mi->groups[MINSTREL_CCK_GROUP].supported = mi->cck_supported;
100 +       mi->supported[MINSTREL_CCK_GROUP] = mi->cck_supported;
101  }
102  
103  static void
104 @@ -1233,7 +1233,7 @@ minstrel_ht_update_caps(void *priv, stru
105                 u32 gflags = minstrel_mcs_groups[i].flags;
106                 int bw, nss;
107  
108 -               mi->groups[i].supported = 0;
109 +               mi->supported[i] = 0;
110                 if (i == MINSTREL_CCK_GROUP) {
111                         minstrel_ht_update_cck(mp, mi, sband, sta);
112                         continue;
113 @@ -1265,8 +1265,8 @@ minstrel_ht_update_caps(void *priv, stru
114                         if (use_vht && minstrel_vht_only)
115                                 continue;
116  #endif
117 -                       mi->groups[i].supported = mcs->rx_mask[nss - 1];
118 -                       if (mi->groups[i].supported)
119 +                       mi->supported[i] = mcs->rx_mask[nss - 1];
120 +                       if (mi->supported[i])
121                                 n_supported++;
122                         continue;
123                 }
124 @@ -1292,10 +1292,10 @@ minstrel_ht_update_caps(void *priv, stru
125                 else
126                         bw = BW_20;
127  
128 -               mi->groups[i].supported = minstrel_get_valid_vht_rates(bw, nss,
129 +               mi->supported[i] = minstrel_get_valid_vht_rates(bw, nss,
130                                 vht_cap->vht_mcs.tx_mcs_map);
131  
132 -               if (mi->groups[i].supported)
133 +               if (mi->supported[i])
134                         n_supported++;
135         }
136  
137 --- a/net/mac80211/rc80211_minstrel_ht.h
138 +++ b/net/mac80211/rc80211_minstrel_ht.h
139 @@ -52,9 +52,6 @@ struct minstrel_mcs_group_data {
140         u8 index;
141         u8 column;
142  
143 -       /* bitfield of supported MCS rates of this group */
144 -       u16 supported;
145 -
146         /* sorted rate set within a MCS group*/
147         u16 max_group_tp_rate[MAX_THR_RATES];
148         u16 max_group_prob_rate;
149 @@ -101,6 +98,9 @@ struct minstrel_ht_sta {
150         u8 cck_supported;
151         u8 cck_supported_short;
152  
153 +       /* Bitfield of supported MCS rates of all groups */
154 +       u16 supported[MINSTREL_GROUPS_NB];
155 +
156         /* MCS rate group info and statistics */
157         struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
158  };
159 --- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
160 +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
161 @@ -24,7 +24,7 @@ minstrel_ht_stats_dump(struct minstrel_h
162         char gimode = 'L';
163         u32 gflags;
164  
165 -       if (!mi->groups[i].supported)
166 +       if (!mi->supported[i])
167                 return p;
168  
169         mg = &minstrel_mcs_groups[i];
170 @@ -42,7 +42,7 @@ minstrel_ht_stats_dump(struct minstrel_h
171                 static const int bitrates[4] = { 10, 20, 55, 110 };
172                 int idx = i * MCS_GROUP_RATES + j;
173  
174 -               if (!(mi->groups[i].supported & BIT(j)))
175 +               if (!(mi->supported[i] & BIT(j)))
176                         continue;
177  
178                 if (gflags & IEEE80211_TX_RC_MCS) {
179 @@ -170,7 +170,7 @@ minstrel_ht_stats_csv_dump(struct minstr
180         char gimode = 'L';
181         u32 gflags;
182  
183 -       if (!mi->groups[i].supported)
184 +       if (!mi->supported[i])
185                 return p;
186  
187         mg = &minstrel_mcs_groups[i];
188 @@ -188,7 +188,7 @@ minstrel_ht_stats_csv_dump(struct minstr
189                 static const int bitrates[4] = { 10, 20, 55, 110 };
190                 int idx = i * MCS_GROUP_RATES + j;
191  
192 -               if (!(mi->groups[i].supported & BIT(j)))
193 +               if (!(mi->supported[i] & BIT(j)))
194                         continue;
195  
196                 if (gflags & IEEE80211_TX_RC_MCS) {