iwlwifi: use iwl_hwrate_get_mac80211_idx where appropriate
For HT packets, mac80211 expects the rate_idx to be an MCS number, which is the lower byte of rate_n_flags. However, iwl_hwrate_to_plcp_idx takes the MCS number and reduces it down to the range 0-8 (6 to 60 Mbps), removing the bits that signify multiply streams, HT40 Duplicate mode, or unequal modulation. This version is used for various internal purposes through the driver. Add the function iwl_hwrate_get_mac80211_idx, an alternate version which takes the rate and the band and returns the mac80211 index (MCS, for HT packets, and PLCP rate, for legacy packets). Signed-off-by: Daniel C Halperin <daniel.c.halperin@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
b58ef214b7
commit
31513be8a0
@@ -96,7 +96,6 @@ EXPORT_SYMBOL(iwl_rates);
|
||||
void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
|
||||
struct ieee80211_tx_info *info)
|
||||
{
|
||||
int rate_index;
|
||||
struct ieee80211_tx_rate *r = &info->control.rates[0];
|
||||
|
||||
info->antenna_sel_tx =
|
||||
@@ -111,10 +110,7 @@ void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
|
||||
r->flags |= IEEE80211_TX_RC_DUP_DATA;
|
||||
if (rate_n_flags & RATE_MCS_SGI_MSK)
|
||||
r->flags |= IEEE80211_TX_RC_SHORT_GI;
|
||||
rate_index = iwl_hwrate_to_plcp_idx(rate_n_flags);
|
||||
if (info->band == IEEE80211_BAND_5GHZ)
|
||||
rate_index -= IWL_FIRST_OFDM_RATE;
|
||||
r->idx = rate_index;
|
||||
r->idx = iwl_hwrate_to_mac80211_idx(rate_n_flags, info->band);
|
||||
}
|
||||
EXPORT_SYMBOL(iwl_hwrate_to_tx_control);
|
||||
|
||||
@@ -149,6 +145,27 @@ int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
|
||||
}
|
||||
EXPORT_SYMBOL(iwl_hwrate_to_plcp_idx);
|
||||
|
||||
int iwl_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band)
|
||||
{
|
||||
int idx = 0;
|
||||
int band_offset = 0;
|
||||
|
||||
/* HT rate format: mac80211 wants an MCS number, which is just LSB */
|
||||
if (rate_n_flags & RATE_MCS_HT_MSK) {
|
||||
idx = (rate_n_flags & 0xff);
|
||||
return idx;
|
||||
/* Legacy rate format, search for match in table */
|
||||
} else {
|
||||
if (band == IEEE80211_BAND_5GHZ)
|
||||
band_offset = IWL_FIRST_OFDM_RATE;
|
||||
for (idx = band_offset; idx < IWL_RATE_COUNT_LEGACY; idx++)
|
||||
if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
|
||||
return idx - band_offset;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant)
|
||||
{
|
||||
int i;
|
||||
|
Reference in New Issue
Block a user