aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHenning Rogge <hrogge@googlemail.com>2008-12-11 16:04:19 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-12-19 15:04:54 -0500
commit420e7fabd9c6d907280ed6b3e40eef425c5d8d8d (patch)
tree6effc9f9386746d1aeb953e32fe82b0a5a5fdf18 /net
parent221b3d60cbb2740ec7d46a4f1ea6d3318a112e51 (diff)
nl80211: Add signal strength and bandwith to nl80211station info
This patch adds signal strength and transmission bitrate to the station_info of nl80211. Signed-off-by: Henning Rogge <rogge@fgan.de> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/cfg.c25
-rw-r--r--net/wireless/nl80211.c58
2 files changed, 81 insertions, 2 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 7912eb14eca0..23b5eeaf7bc5 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -310,12 +310,35 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
310 310
311 sinfo->filled = STATION_INFO_INACTIVE_TIME | 311 sinfo->filled = STATION_INFO_INACTIVE_TIME |
312 STATION_INFO_RX_BYTES | 312 STATION_INFO_RX_BYTES |
313 STATION_INFO_TX_BYTES; 313 STATION_INFO_TX_BYTES |
314 STATION_INFO_TX_BITRATE;
314 315
315 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); 316 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
316 sinfo->rx_bytes = sta->rx_bytes; 317 sinfo->rx_bytes = sta->rx_bytes;
317 sinfo->tx_bytes = sta->tx_bytes; 318 sinfo->tx_bytes = sta->tx_bytes;
318 319
320 if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
321 sinfo->filled |= STATION_INFO_SIGNAL;
322 sinfo->signal = (s8)sta->last_signal;
323 }
324
325 sinfo->txrate.flags = 0;
326 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
327 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
328 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
329 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
330 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
331 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
332
333 if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) {
334 struct ieee80211_supported_band *sband;
335 sband = sta->local->hw.wiphy->bands[
336 sta->local->hw.conf.channel->band];
337 sinfo->txrate.legacy =
338 sband->bitrates[sta->last_tx_rate.idx].bitrate;
339 } else
340 sinfo->txrate.mcs = sta->last_tx_rate.idx;
341
319 if (ieee80211_vif_is_mesh(&sdata->vif)) { 342 if (ieee80211_vif_is_mesh(&sdata->vif)) {
320#ifdef CONFIG_MAC80211_MESH 343#ifdef CONFIG_MAC80211_MESH
321 sinfo->filled |= STATION_INFO_LLID | 344 sinfo->filled |= STATION_INFO_LLID |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4335f76be71f..93c9b983ce08 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1091,12 +1091,46 @@ static int parse_station_flags(struct nlattr *nla, u32 *staflags)
1091 return 0; 1091 return 0;
1092} 1092}
1093 1093
1094static u16 nl80211_calculate_bitrate(struct rate_info *rate)
1095{
1096 int modulation, streams, bitrate;
1097
1098 if (!(rate->flags & RATE_INFO_FLAGS_MCS))
1099 return rate->legacy;
1100
1101 /* the formula below does only work for MCS values smaller than 32 */
1102 if (rate->mcs >= 32)
1103 return 0;
1104
1105 modulation = rate->mcs & 7;
1106 streams = (rate->mcs >> 3) + 1;
1107
1108 bitrate = (rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) ?
1109 13500000 : 6500000;
1110
1111 if (modulation < 4)
1112 bitrate *= (modulation + 1);
1113 else if (modulation == 4)
1114 bitrate *= (modulation + 2);
1115 else
1116 bitrate *= (modulation + 3);
1117
1118 bitrate *= streams;
1119
1120 if (rate->flags & RATE_INFO_FLAGS_SHORT_GI)
1121 bitrate = (bitrate / 9) * 10;
1122
1123 /* do NOT round down here */
1124 return (bitrate + 50000) / 100000;
1125}
1126
1094static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, 1127static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
1095 int flags, struct net_device *dev, 1128 int flags, struct net_device *dev,
1096 u8 *mac_addr, struct station_info *sinfo) 1129 u8 *mac_addr, struct station_info *sinfo)
1097{ 1130{
1098 void *hdr; 1131 void *hdr;
1099 struct nlattr *sinfoattr; 1132 struct nlattr *sinfoattr, *txrate;
1133 u16 bitrate;
1100 1134
1101 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION); 1135 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
1102 if (!hdr) 1136 if (!hdr)
@@ -1126,7 +1160,29 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
1126 if (sinfo->filled & STATION_INFO_PLINK_STATE) 1160 if (sinfo->filled & STATION_INFO_PLINK_STATE)
1127 NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE, 1161 NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE,
1128 sinfo->plink_state); 1162 sinfo->plink_state);
1163 if (sinfo->filled & STATION_INFO_SIGNAL)
1164 NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL,
1165 sinfo->signal);
1166 if (sinfo->filled & STATION_INFO_TX_BITRATE) {
1167 txrate = nla_nest_start(msg, NL80211_STA_INFO_TX_BITRATE);
1168 if (!txrate)
1169 goto nla_put_failure;
1170
1171 /* nl80211_calculate_bitrate will return 0 for mcs >= 32 */
1172 bitrate = nl80211_calculate_bitrate(&sinfo->txrate);
1173 if (bitrate > 0)
1174 NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate);
1129 1175
1176 if (sinfo->txrate.flags & RATE_INFO_FLAGS_MCS)
1177 NLA_PUT_U8(msg, NL80211_RATE_INFO_MCS,
1178 sinfo->txrate.mcs);
1179 if (sinfo->txrate.flags & RATE_INFO_FLAGS_40_MHZ_WIDTH)
1180 NLA_PUT_FLAG(msg, NL80211_RATE_INFO_40_MHZ_WIDTH);
1181 if (sinfo->txrate.flags & RATE_INFO_FLAGS_SHORT_GI)
1182 NLA_PUT_FLAG(msg, NL80211_RATE_INFO_SHORT_GI);
1183
1184 nla_nest_end(msg, txrate);
1185 }
1130 nla_nest_end(msg, sinfoattr); 1186 nla_nest_end(msg, sinfoattr);
1131 1187
1132 return genlmsg_end(msg, hdr); 1188 return genlmsg_end(msg, hdr);