diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-02-27 16:08:01 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-03-01 13:48:21 -0500 |
commit | 3af6334c9e4fbf41ef0ebd3b4d5762f26b675c40 (patch) | |
tree | ffc05f816754d2393963ee13f4c7a3eb515e0627 | |
parent | c8dcfd8a046c1f49af0c15726761af17b957962d (diff) |
mac80211: add support for showing the last rx bitrate
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/cfg.c | 31 | ||||
-rw-r--r-- | net/mac80211/rx.c | 11 | ||||
-rw-r--r-- | net/mac80211/sta_info.h | 4 |
3 files changed, 36 insertions, 10 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 8b436c768c4e..7b701dcddb50 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -316,6 +316,17 @@ static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, | |||
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | 318 | ||
319 | static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx) | ||
320 | { | ||
321 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) { | ||
322 | struct ieee80211_supported_band *sband; | ||
323 | sband = sta->local->hw.wiphy->bands[ | ||
324 | sta->local->hw.conf.channel->band]; | ||
325 | rate->legacy = sband->bitrates[idx].bitrate; | ||
326 | } else | ||
327 | rate->mcs = idx; | ||
328 | } | ||
329 | |||
319 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | 330 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
320 | { | 331 | { |
321 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 332 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
@@ -330,6 +341,7 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
330 | STATION_INFO_TX_RETRIES | | 341 | STATION_INFO_TX_RETRIES | |
331 | STATION_INFO_TX_FAILED | | 342 | STATION_INFO_TX_FAILED | |
332 | STATION_INFO_TX_BITRATE | | 343 | STATION_INFO_TX_BITRATE | |
344 | STATION_INFO_RX_BITRATE | | ||
333 | STATION_INFO_RX_DROP_MISC; | 345 | STATION_INFO_RX_DROP_MISC; |
334 | 346 | ||
335 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); | 347 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
@@ -355,15 +367,16 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
355 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; | 367 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
356 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) | 368 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) |
357 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; | 369 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
358 | 370 | rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx); | |
359 | if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) { | 371 | |
360 | struct ieee80211_supported_band *sband; | 372 | sinfo->rxrate.flags = 0; |
361 | sband = sta->local->hw.wiphy->bands[ | 373 | if (sta->last_rx_rate_flag & RX_FLAG_HT) |
362 | sta->local->hw.conf.channel->band]; | 374 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; |
363 | sinfo->txrate.legacy = | 375 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) |
364 | sband->bitrates[sta->last_tx_rate.idx].bitrate; | 376 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
365 | } else | 377 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) |
366 | sinfo->txrate.mcs = sta->last_tx_rate.idx; | 378 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
379 | rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx); | ||
367 | 380 | ||
368 | if (ieee80211_vif_is_mesh(&sdata->vif)) { | 381 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
369 | #ifdef CONFIG_MAC80211_MESH | 382 | #ifdef CONFIG_MAC80211_MESH |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 5b534235d6be..5c1930ba8ebe 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1156,14 +1156,23 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
1156 | if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { | 1156 | if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
1157 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, | 1157 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, |
1158 | NL80211_IFTYPE_ADHOC); | 1158 | NL80211_IFTYPE_ADHOC); |
1159 | if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) | 1159 | if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) { |
1160 | sta->last_rx = jiffies; | 1160 | sta->last_rx = jiffies; |
1161 | if (ieee80211_is_data(hdr->frame_control)) { | ||
1162 | sta->last_rx_rate_idx = status->rate_idx; | ||
1163 | sta->last_rx_rate_flag = status->flag; | ||
1164 | } | ||
1165 | } | ||
1161 | } else if (!is_multicast_ether_addr(hdr->addr1)) { | 1166 | } else if (!is_multicast_ether_addr(hdr->addr1)) { |
1162 | /* | 1167 | /* |
1163 | * Mesh beacons will update last_rx when if they are found to | 1168 | * Mesh beacons will update last_rx when if they are found to |
1164 | * match the current local configuration when processed. | 1169 | * match the current local configuration when processed. |
1165 | */ | 1170 | */ |
1166 | sta->last_rx = jiffies; | 1171 | sta->last_rx = jiffies; |
1172 | if (ieee80211_is_data(hdr->frame_control)) { | ||
1173 | sta->last_rx_rate_idx = status->rate_idx; | ||
1174 | sta->last_rx_rate_flag = status->flag; | ||
1175 | } | ||
1167 | } | 1176 | } |
1168 | 1177 | ||
1169 | if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) | 1178 | if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index ca0b69060ef7..57681149e37f 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -209,6 +209,8 @@ enum plink_state { | |||
209 | * @rate_ctrl_priv: rate control private per-STA pointer | 209 | * @rate_ctrl_priv: rate control private per-STA pointer |
210 | * @last_tx_rate: rate used for last transmit, to report to userspace as | 210 | * @last_tx_rate: rate used for last transmit, to report to userspace as |
211 | * "the" transmit rate | 211 | * "the" transmit rate |
212 | * @last_rx_rate_idx: rx status rate index of the last data packet | ||
213 | * @last_rx_rate_flag: rx status flag of the last data packet | ||
212 | * @lock: used for locking all fields that require locking, see comments | 214 | * @lock: used for locking all fields that require locking, see comments |
213 | * in the header file. | 215 | * in the header file. |
214 | * @flaglock: spinlock for flags accesses | 216 | * @flaglock: spinlock for flags accesses |
@@ -311,6 +313,8 @@ struct sta_info { | |||
311 | unsigned long tx_bytes; | 313 | unsigned long tx_bytes; |
312 | unsigned long tx_fragments; | 314 | unsigned long tx_fragments; |
313 | struct ieee80211_tx_rate last_tx_rate; | 315 | struct ieee80211_tx_rate last_tx_rate; |
316 | int last_rx_rate_idx; | ||
317 | int last_rx_rate_flag; | ||
314 | u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; | 318 | u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; |
315 | 319 | ||
316 | /* | 320 | /* |