aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/util.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-06-30 08:08:12 -0400
committerDavid S. Miller <davem@davemloft.net>2018-06-30 08:08:12 -0400
commit8365da2c0570f02615e7f1d2d729d854029202b0 (patch)
tree223ab9641411c401269e5da80f260cafaf40eedc /net/wireless/util.c
parenta1be5a20f137bdf436bab86c18998229908ce951 (diff)
parenta4217750586975dee7d6dd8829a1be24a7678b3d (diff)
Merge tag 'mac80211-next-for-davem-2018-06-29' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
Small merge conflict in net/mac80211/scan.c, I preserved the kcalloc() conversion. -DaveM Johannes Berg says: ==================== This round's updates: * finally some of the promised HE code, but it turns out to be small - but everything kept changing, so one part I did in the driver was >30 patches for what was ultimately <200 lines of code ... similar here for this code. * improved scan privacy support - can now specify scan flags for randomizing the sequence number as well as reducing the probe request element content * rfkill cleanups * a timekeeping cleanup from Arnd * various other cleanups ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r--net/wireless/util.c87
1 files changed, 85 insertions, 2 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 3c654cd7ba56..e0825a019e9f 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net> 5 * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2017 Intel Deutschland GmbH
7 */ 8 */
8#include <linux/export.h> 9#include <linux/export.h>
9#include <linux/bitops.h> 10#include <linux/bitops.h>
@@ -1142,6 +1143,85 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
1142 return 0; 1143 return 0;
1143} 1144}
1144 1145
1146static u32 cfg80211_calculate_bitrate_he(struct rate_info *rate)
1147{
1148#define SCALE 2048
1149 u16 mcs_divisors[12] = {
1150 34133, /* 16.666666... */
1151 17067, /* 8.333333... */
1152 11378, /* 5.555555... */
1153 8533, /* 4.166666... */
1154 5689, /* 2.777777... */
1155 4267, /* 2.083333... */
1156 3923, /* 1.851851... */
1157 3413, /* 1.666666... */
1158 2844, /* 1.388888... */
1159 2560, /* 1.250000... */
1160 2276, /* 1.111111... */
1161 2048, /* 1.000000... */
1162 };
1163 u32 rates_160M[3] = { 960777777, 907400000, 816666666 };
1164 u32 rates_969[3] = { 480388888, 453700000, 408333333 };
1165 u32 rates_484[3] = { 229411111, 216666666, 195000000 };
1166 u32 rates_242[3] = { 114711111, 108333333, 97500000 };
1167 u32 rates_106[3] = { 40000000, 37777777, 34000000 };
1168 u32 rates_52[3] = { 18820000, 17777777, 16000000 };
1169 u32 rates_26[3] = { 9411111, 8888888, 8000000 };
1170 u64 tmp;
1171 u32 result;
1172
1173 if (WARN_ON_ONCE(rate->mcs > 11))
1174 return 0;
1175
1176 if (WARN_ON_ONCE(rate->he_gi > NL80211_RATE_INFO_HE_GI_3_2))
1177 return 0;
1178 if (WARN_ON_ONCE(rate->he_ru_alloc >
1179 NL80211_RATE_INFO_HE_RU_ALLOC_2x996))
1180 return 0;
1181 if (WARN_ON_ONCE(rate->nss < 1 || rate->nss > 8))
1182 return 0;
1183
1184 if (rate->bw == RATE_INFO_BW_160)
1185 result = rates_160M[rate->he_gi];
1186 else if (rate->bw == RATE_INFO_BW_80 ||
1187 (rate->bw == RATE_INFO_BW_HE_RU &&
1188 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_996))
1189 result = rates_969[rate->he_gi];
1190 else if (rate->bw == RATE_INFO_BW_40 ||
1191 (rate->bw == RATE_INFO_BW_HE_RU &&
1192 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_484))
1193 result = rates_484[rate->he_gi];
1194 else if (rate->bw == RATE_INFO_BW_20 ||
1195 (rate->bw == RATE_INFO_BW_HE_RU &&
1196 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_242))
1197 result = rates_242[rate->he_gi];
1198 else if (rate->bw == RATE_INFO_BW_HE_RU &&
1199 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_106)
1200 result = rates_106[rate->he_gi];
1201 else if (rate->bw == RATE_INFO_BW_HE_RU &&
1202 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_52)
1203 result = rates_52[rate->he_gi];
1204 else if (rate->bw == RATE_INFO_BW_HE_RU &&
1205 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_26)
1206 result = rates_26[rate->he_gi];
1207 else if (WARN(1, "invalid HE MCS: bw:%d, ru:%d\n",
1208 rate->bw, rate->he_ru_alloc))
1209 return 0;
1210
1211 /* now scale to the appropriate MCS */
1212 tmp = result;
1213 tmp *= SCALE;
1214 do_div(tmp, mcs_divisors[rate->mcs]);
1215 result = tmp;
1216
1217 /* and take NSS, DCM into account */
1218 result = (result * rate->nss) / 8;
1219 if (rate->he_dcm)
1220 result /= 2;
1221
1222 return result;
1223}
1224
1145u32 cfg80211_calculate_bitrate(struct rate_info *rate) 1225u32 cfg80211_calculate_bitrate(struct rate_info *rate)
1146{ 1226{
1147 if (rate->flags & RATE_INFO_FLAGS_MCS) 1227 if (rate->flags & RATE_INFO_FLAGS_MCS)
@@ -1150,6 +1230,8 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate)
1150 return cfg80211_calculate_bitrate_60g(rate); 1230 return cfg80211_calculate_bitrate_60g(rate);
1151 if (rate->flags & RATE_INFO_FLAGS_VHT_MCS) 1231 if (rate->flags & RATE_INFO_FLAGS_VHT_MCS)
1152 return cfg80211_calculate_bitrate_vht(rate); 1232 return cfg80211_calculate_bitrate_vht(rate);
1233 if (rate->flags & RATE_INFO_FLAGS_HE_MCS)
1234 return cfg80211_calculate_bitrate_he(rate);
1153 1235
1154 return rate->legacy; 1236 return rate->legacy;
1155} 1237}
@@ -1791,8 +1873,9 @@ bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
1791 1873
1792int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp) 1874int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp)
1793{ 1875{
1794 sinfo->pertid = kcalloc(sizeof(*(sinfo->pertid)), 1876 sinfo->pertid = kcalloc(IEEE80211_NUM_TIDS + 1,
1795 IEEE80211_NUM_TIDS + 1, gfp); 1877 sizeof(*(sinfo->pertid)),
1878 gfp);
1796 if (!sinfo->pertid) 1879 if (!sinfo->pertid)
1797 return -ENOMEM; 1880 return -ENOMEM;
1798 1881