diff options
Diffstat (limited to 'net/wireless/wext-compat.c')
-rw-r--r-- | net/wireless/wext-compat.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 3a5f999703f1..226cf8609079 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -1156,3 +1156,62 @@ int cfg80211_wext_giwrate(struct net_device *dev, | |||
1156 | return 0; | 1156 | return 0; |
1157 | } | 1157 | } |
1158 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrate); | 1158 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrate); |
1159 | |||
1160 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ | ||
1161 | struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) | ||
1162 | { | ||
1163 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
1164 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
1165 | /* we are under RTNL - globally locked - so can use static structs */ | ||
1166 | static struct iw_statistics wstats; | ||
1167 | static struct station_info sinfo; | ||
1168 | u8 *addr; | ||
1169 | |||
1170 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) | ||
1171 | return NULL; | ||
1172 | |||
1173 | if (!rdev->ops->get_station) | ||
1174 | return NULL; | ||
1175 | |||
1176 | addr = wdev->wext.connect.bssid; | ||
1177 | if (!addr) | ||
1178 | return NULL; | ||
1179 | |||
1180 | if (rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo)) | ||
1181 | return NULL; | ||
1182 | |||
1183 | memset(&wstats, 0, sizeof(wstats)); | ||
1184 | |||
1185 | switch (rdev->wiphy.signal_type) { | ||
1186 | case CFG80211_SIGNAL_TYPE_MBM: | ||
1187 | if (sinfo.filled & STATION_INFO_SIGNAL) { | ||
1188 | int sig = sinfo.signal; | ||
1189 | wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; | ||
1190 | wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; | ||
1191 | wstats.qual.updated |= IW_QUAL_DBM; | ||
1192 | wstats.qual.level = sig; | ||
1193 | if (sig < -110) | ||
1194 | sig = -110; | ||
1195 | else if (sig > -40) | ||
1196 | sig = -40; | ||
1197 | wstats.qual.qual = sig + 110; | ||
1198 | break; | ||
1199 | } | ||
1200 | case CFG80211_SIGNAL_TYPE_UNSPEC: | ||
1201 | if (sinfo.filled & STATION_INFO_SIGNAL) { | ||
1202 | wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; | ||
1203 | wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; | ||
1204 | wstats.qual.level = sinfo.signal; | ||
1205 | wstats.qual.qual = sinfo.signal; | ||
1206 | break; | ||
1207 | } | ||
1208 | default: | ||
1209 | wstats.qual.updated |= IW_QUAL_LEVEL_INVALID; | ||
1210 | wstats.qual.updated |= IW_QUAL_QUAL_INVALID; | ||
1211 | } | ||
1212 | |||
1213 | wstats.qual.updated |= IW_QUAL_NOISE_INVALID; | ||
1214 | |||
1215 | return &wstats; | ||
1216 | } | ||
1217 | EXPORT_SYMBOL_GPL(cfg80211_wireless_stats); | ||