cfg80211/mac80211: Use more generic bitrate mask for rate control

Extend struct cfg80211_bitrate_mask to actually use a bitfield mask
instead of just a single fixed or maximum rate index. This change
itself does not modify the behavior (except for debugfs files), but it
prepares cfg80211 and mac80211 for a new nl80211 command for setting
which rates can be used in TX rate control.

Since frames are now going through the rate control algorithm
unconditionally, the internal IEEE80211_TX_INTFL_RCALGO flag can now
be removed. The RC implementations can use the rate_idx_mask value to
optimize their behavior if only a single rate is enabled.

The old max_rate_idx in struct ieee80211_tx_rate_control is maintained
(but commented as deprecated) for backwards compatibility with existing
RC implementations. Once these implementations have been updated to
use the more generic rate_idx_mask, the max_rate_idx value can be
removed.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Jouni Malinen
2010-01-06 13:09:08 +02:00
committed by John W. Linville
parent e00cfce0cb
commit 37eb0b164c
10 changed files with 122 additions and 79 deletions

View File

@@ -1204,21 +1204,47 @@ int cfg80211_wext_siwrate(struct net_device *dev,
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
struct cfg80211_bitrate_mask mask;
u32 fixed, maxrate;
struct ieee80211_supported_band *sband;
int band, ridx;
bool match = false;
if (!rdev->ops->set_bitrate_mask)
return -EOPNOTSUPP;
mask.fixed = 0;
mask.maxrate = 0;
memset(&mask, 0, sizeof(mask));
fixed = 0;
maxrate = 0;
if (rate->value < 0) {
/* nothing */
} else if (rate->fixed) {
mask.fixed = rate->value / 1000; /* kbps */
fixed = rate->value / 100000;
} else {
mask.maxrate = rate->value / 1000; /* kbps */
maxrate = rate->value / 100000;
}
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
sband = wdev->wiphy->bands[band];
if (sband == NULL)
continue;
for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
struct ieee80211_rate *srate = &sband->bitrates[ridx];
if (fixed == srate->bitrate) {
mask.control[band].legacy = 1 << ridx;
match = true;
break;
}
if (srate->bitrate <= maxrate) {
mask.control[band].legacy |= 1 << ridx;
match = true;
}
}
}
if (!match)
return -EINVAL;
return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask);
}
EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate);