diff options
author | Saravana <saravanad@posedge.com> | 2012-11-28 07:59:38 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-11-29 09:33:05 -0500 |
commit | 003e676af5044c2168dafbb49c7b8d61dd68cc60 (patch) | |
tree | df109c33b23c9013d400af440dadc83fccd4a040 /net/mac80211/cfg.c | |
parent | 91b8c050b2a2ed3a1277de53d90e1899f28225e8 (diff) |
mac80211: re-organize the rx rate calculation logic
Currently the logic to fill a struct rate_info with
a STA's last RX rate is accessible only in the cfg.c.
As the RX rate calculation might be needed elsewhere,
split this out into a separate function.
Signed-off-by: Saravana <saravanad@posedge.com>
[fix various whitespace issues, reword commit log]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r-- | net/mac80211/cfg.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 97cf615eb36a..d6456107c373 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -398,6 +398,38 @@ void sta_set_rate_info_tx(struct sta_info *sta, | |||
398 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; | 398 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; |
399 | } | 399 | } |
400 | 400 | ||
401 | void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo) | ||
402 | { | ||
403 | rinfo->flags = 0; | ||
404 | |||
405 | if (sta->last_rx_rate_flag & RX_FLAG_HT) { | ||
406 | rinfo->flags |= RATE_INFO_FLAGS_MCS; | ||
407 | rinfo->mcs = sta->last_rx_rate_idx; | ||
408 | } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) { | ||
409 | rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; | ||
410 | rinfo->nss = sta->last_rx_rate_vht_nss; | ||
411 | rinfo->mcs = sta->last_rx_rate_idx; | ||
412 | } else { | ||
413 | struct ieee80211_supported_band *sband; | ||
414 | |||
415 | sband = sta->local->hw.wiphy->bands[ | ||
416 | ieee80211_get_sdata_band(sta->sdata)]; | ||
417 | rinfo->legacy = | ||
418 | sband->bitrates[sta->last_rx_rate_idx].bitrate; | ||
419 | } | ||
420 | |||
421 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) | ||
422 | rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; | ||
423 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) | ||
424 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; | ||
425 | if (sta->last_rx_rate_flag & RX_FLAG_80MHZ) | ||
426 | rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; | ||
427 | if (sta->last_rx_rate_flag & RX_FLAG_80P80MHZ) | ||
428 | rinfo->flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH; | ||
429 | if (sta->last_rx_rate_flag & RX_FLAG_160MHZ) | ||
430 | rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; | ||
431 | } | ||
432 | |||
401 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | 433 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
402 | { | 434 | { |
403 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 435 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
@@ -444,34 +476,7 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
444 | } | 476 | } |
445 | 477 | ||
446 | sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); | 478 | sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); |
447 | 479 | sta_set_rate_info_rx(sta, &sinfo->rxrate); | |
448 | sinfo->rxrate.flags = 0; | ||
449 | if (sta->last_rx_rate_flag & RX_FLAG_HT) { | ||
450 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; | ||
451 | sinfo->rxrate.mcs = sta->last_rx_rate_idx; | ||
452 | } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) { | ||
453 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_VHT_MCS; | ||
454 | sinfo->rxrate.nss = sta->last_rx_rate_vht_nss; | ||
455 | sinfo->rxrate.mcs = sta->last_rx_rate_idx; | ||
456 | } else { | ||
457 | struct ieee80211_supported_band *sband; | ||
458 | |||
459 | sband = sta->local->hw.wiphy->bands[ | ||
460 | ieee80211_get_sdata_band(sta->sdata)]; | ||
461 | sinfo->rxrate.legacy = | ||
462 | sband->bitrates[sta->last_rx_rate_idx].bitrate; | ||
463 | } | ||
464 | |||
465 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) | ||
466 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; | ||
467 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) | ||
468 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI; | ||
469 | if (sta->last_rx_rate_flag & RX_FLAG_80MHZ) | ||
470 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; | ||
471 | if (sta->last_rx_rate_flag & RX_FLAG_80P80MHZ) | ||
472 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH; | ||
473 | if (sta->last_rx_rate_flag & RX_FLAG_160MHZ) | ||
474 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; | ||
475 | 480 | ||
476 | if (ieee80211_vif_is_mesh(&sdata->vif)) { | 481 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
477 | #ifdef CONFIG_MAC80211_MESH | 482 | #ifdef CONFIG_MAC80211_MESH |