aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>2012-01-28 11:25:32 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-01-30 15:48:25 -0500
commit24db78c05b1e3ccb5a78aedd17aa1008c91dab5a (patch)
treef41babc8ada871a26619be23f983121ad557da91 /net/wireless/nl80211.c
parentd273bb20c00340748e3ca9730f87524ec5abbd64 (diff)
nl80211: add support for mcs masks
Allow to set mcs masks through nl80211. We also allow to set MCS rates but no legacy rates (and vice versa). Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c42173f947ef..c910b0750dc2 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5393,9 +5393,39 @@ static u32 rateset_to_mask(struct ieee80211_supported_band *sband,
5393 return mask; 5393 return mask;
5394} 5394}
5395 5395
5396static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband,
5397 u8 *rates, u8 rates_len,
5398 u8 mcs[IEEE80211_HT_MCS_MASK_LEN])
5399{
5400 u8 i;
5401
5402 memset(mcs, 0, IEEE80211_HT_MCS_MASK_LEN);
5403
5404 for (i = 0; i < rates_len; i++) {
5405 int ridx, rbit;
5406
5407 ridx = rates[i] / 8;
5408 rbit = BIT(rates[i] % 8);
5409
5410 /* check validity */
5411 if ((ridx < 0) || (ridx > IEEE80211_HT_MCS_MASK_LEN))
5412 return false;
5413
5414 /* check availability */
5415 if (sband->ht_cap.mcs.rx_mask[ridx] & rbit)
5416 mcs[ridx] |= rbit;
5417 else
5418 return false;
5419 }
5420
5421 return true;
5422}
5423
5396static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { 5424static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = {
5397 [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY, 5425 [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY,
5398 .len = NL80211_MAX_SUPP_RATES }, 5426 .len = NL80211_MAX_SUPP_RATES },
5427 [NL80211_TXRATE_MCS] = { .type = NLA_BINARY,
5428 .len = NL80211_MAX_SUPP_HT_RATES },
5399}; 5429};
5400 5430
5401static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, 5431static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
@@ -5421,12 +5451,20 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
5421 sband = rdev->wiphy.bands[i]; 5451 sband = rdev->wiphy.bands[i];
5422 mask.control[i].legacy = 5452 mask.control[i].legacy =
5423 sband ? (1 << sband->n_bitrates) - 1 : 0; 5453 sband ? (1 << sband->n_bitrates) - 1 : 0;
5454 if (sband)
5455 memcpy(mask.control[i].mcs,
5456 sband->ht_cap.mcs.rx_mask,
5457 sizeof(mask.control[i].mcs));
5458 else
5459 memset(mask.control[i].mcs, 0,
5460 sizeof(mask.control[i].mcs));
5424 } 5461 }
5425 5462
5426 /* 5463 /*
5427 * The nested attribute uses enum nl80211_band as the index. This maps 5464 * The nested attribute uses enum nl80211_band as the index. This maps
5428 * directly to the enum ieee80211_band values used in cfg80211. 5465 * directly to the enum ieee80211_band values used in cfg80211.
5429 */ 5466 */
5467 BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
5430 nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) 5468 nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
5431 { 5469 {
5432 enum ieee80211_band band = nla_type(tx_rates); 5470 enum ieee80211_band band = nla_type(tx_rates);
@@ -5442,7 +5480,28 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
5442 sband, 5480 sband,
5443 nla_data(tb[NL80211_TXRATE_LEGACY]), 5481 nla_data(tb[NL80211_TXRATE_LEGACY]),
5444 nla_len(tb[NL80211_TXRATE_LEGACY])); 5482 nla_len(tb[NL80211_TXRATE_LEGACY]));
5445 if (mask.control[band].legacy == 0) 5483 }
5484 if (tb[NL80211_TXRATE_MCS]) {
5485 if (!ht_rateset_to_mask(
5486 sband,
5487 nla_data(tb[NL80211_TXRATE_MCS]),
5488 nla_len(tb[NL80211_TXRATE_MCS]),
5489 mask.control[band].mcs))
5490 return -EINVAL;
5491 }
5492
5493 if (mask.control[band].legacy == 0) {
5494 /* don't allow empty legacy rates if HT
5495 * is not even supported. */
5496 if (!rdev->wiphy.bands[band]->ht_cap.ht_supported)
5497 return -EINVAL;
5498
5499 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
5500 if (mask.control[band].mcs[i])
5501 break;
5502
5503 /* legacy and mcs rates may not be both empty */
5504 if (i == IEEE80211_HT_MCS_MASK_LEN)
5446 return -EINVAL; 5505 return -EINVAL;
5447 } 5506 }
5448 } 5507 }