diff options
-rw-r--r-- | include/linux/nl80211.h | 4 | ||||
-rw-r--r-- | include/net/cfg80211.h | 3 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 61 |
3 files changed, 65 insertions, 3 deletions
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 4f98fae13307..ad56e21a9f10 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h | |||
@@ -1475,6 +1475,7 @@ enum nl80211_attrs { | |||
1475 | #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS | 1475 | #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS |
1476 | 1476 | ||
1477 | #define NL80211_MAX_SUPP_RATES 32 | 1477 | #define NL80211_MAX_SUPP_RATES 32 |
1478 | #define NL80211_MAX_SUPP_HT_RATES 77 | ||
1478 | #define NL80211_MAX_SUPP_REG_RULES 32 | 1479 | #define NL80211_MAX_SUPP_REG_RULES 32 |
1479 | #define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0 | 1480 | #define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0 |
1480 | #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16 | 1481 | #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16 |
@@ -2405,12 +2406,15 @@ enum nl80211_key_attributes { | |||
2405 | * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with | 2406 | * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with |
2406 | * 1 = 500 kbps) but without the IE length restriction (at most | 2407 | * 1 = 500 kbps) but without the IE length restriction (at most |
2407 | * %NL80211_MAX_SUPP_RATES in a single array). | 2408 | * %NL80211_MAX_SUPP_RATES in a single array). |
2409 | * @NL80211_TXRATE_MCS: HT (MCS) rates allowed for TX rate selection | ||
2410 | * in an array of MCS numbers. | ||
2408 | * @__NL80211_TXRATE_AFTER_LAST: internal | 2411 | * @__NL80211_TXRATE_AFTER_LAST: internal |
2409 | * @NL80211_TXRATE_MAX: highest TX rate attribute | 2412 | * @NL80211_TXRATE_MAX: highest TX rate attribute |
2410 | */ | 2413 | */ |
2411 | enum nl80211_tx_rate_attributes { | 2414 | enum nl80211_tx_rate_attributes { |
2412 | __NL80211_TXRATE_INVALID, | 2415 | __NL80211_TXRATE_INVALID, |
2413 | NL80211_TXRATE_LEGACY, | 2416 | NL80211_TXRATE_LEGACY, |
2417 | NL80211_TXRATE_MCS, | ||
2414 | 2418 | ||
2415 | /* keep last */ | 2419 | /* keep last */ |
2416 | __NL80211_TXRATE_AFTER_LAST, | 2420 | __NL80211_TXRATE_AFTER_LAST, |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 5bb3ed4f99f5..2964205332f4 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -1232,8 +1232,7 @@ enum wiphy_params_flags { | |||
1232 | struct cfg80211_bitrate_mask { | 1232 | struct cfg80211_bitrate_mask { |
1233 | struct { | 1233 | struct { |
1234 | u32 legacy; | 1234 | u32 legacy; |
1235 | /* TODO: add support for masking MCS rates; e.g.: */ | 1235 | u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; |
1236 | /* u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; */ | ||
1237 | } control[IEEE80211_NUM_BANDS]; | 1236 | } control[IEEE80211_NUM_BANDS]; |
1238 | }; | 1237 | }; |
1239 | /** | 1238 | /** |
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 | ||
5396 | static 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 | |||
5396 | static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { | 5424 | static 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 | ||
5401 | static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, | 5431 | static 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 | } |