aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-10-08 04:59:33 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 18:58:53 -0400
commit7a5158ef8da70fdedeb0530faaa8128aa645be3c (patch)
tree6db285b5fc4971c5e15168fc0fb7cf442b89f168
parente87a2feea75e3cba7af43ed9317b56b282d87742 (diff)
mac80211: fix short slot handling
This patch makes mac80211 handle short slot requests from the AP properly. Also warn about uses of IEEE80211_CONF_SHORT_SLOT_TIME and optimise out the code since it cannot ever be hit anyway. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--include/net/mac80211.h28
-rw-r--r--net/mac80211/main.c9
-rw-r--r--net/mac80211/mlme.c74
3 files changed, 62 insertions, 49 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 2fab5a7e5db7..d1466e7a47b8 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -180,8 +180,12 @@ enum ieee80211_bss_change {
180 * @assoc: association status 180 * @assoc: association status
181 * @aid: association ID number, valid only when @assoc is true 181 * @aid: association ID number, valid only when @assoc is true
182 * @use_cts_prot: use CTS protection 182 * @use_cts_prot: use CTS protection
183 * @use_short_preamble: use 802.11b short preamble 183 * @use_short_preamble: use 802.11b short preamble;
184 * @use_short_slot: use short slot time (only relevant for ERP) 184 * if the hardware cannot handle this it must set the
185 * IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag
186 * @use_short_slot: use short slot time (only relevant for ERP);
187 * if the hardware cannot handle this it must set the
188 * IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag
185 * @dtim_period: num of beacons before the next DTIM, for PSM 189 * @dtim_period: num of beacons before the next DTIM, for PSM
186 * @timestamp: beacon timestamp 190 * @timestamp: beacon timestamp
187 * @beacon_int: beacon interval 191 * @beacon_int: beacon interval
@@ -442,23 +446,23 @@ struct ieee80211_rx_status {
442 * 446 *
443 * Flags to define PHY configuration options 447 * Flags to define PHY configuration options
444 * 448 *
445 * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
446 * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported) 449 * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
447 * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported) 450 * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported)
448 * @IEEE80211_CONF_PS: Enable 802.11 power save mode 451 * @IEEE80211_CONF_PS: Enable 802.11 power save mode
449 */ 452 */
450enum ieee80211_conf_flags { 453enum ieee80211_conf_flags {
451 /* 454 IEEE80211_CONF_RADIOTAP = (1<<0),
452 * TODO: IEEE80211_CONF_SHORT_SLOT_TIME will be removed once drivers 455 IEEE80211_CONF_SUPPORT_HT_MODE = (1<<1),
453 * have been converted to use bss_info_changed() for slot time 456 IEEE80211_CONF_PS = (1<<2),
454 * configuration
455 */
456 IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0),
457 IEEE80211_CONF_RADIOTAP = (1<<1),
458 IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2),
459 IEEE80211_CONF_PS = (1<<3),
460}; 457};
461 458
459/* XXX: remove all this once drivers stop trying to use it */
460static inline int __deprecated __IEEE80211_CONF_SHORT_SLOT_TIME(void)
461{
462 return 0;
463}
464#define IEEE80211_CONF_SHORT_SLOT_TIME (__IEEE80211_CONF_SHORT_SLOT_TIME())
465
462/** 466/**
463 * struct ieee80211_conf - configuration of the device 467 * struct ieee80211_conf - configuration of the device
464 * 468 *
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index d1c4e86b215c..c427954fe8e8 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -346,9 +346,12 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
346 346
347u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata) 347u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata)
348{ 348{
349 sdata->bss_conf.use_cts_prot = 0; 349 sdata->bss_conf.use_cts_prot = false;
350 sdata->bss_conf.use_short_preamble = 0; 350 sdata->bss_conf.use_short_preamble = false;
351 return BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_ERP_PREAMBLE; 351 sdata->bss_conf.use_short_slot = false;
352 return BSS_CHANGED_ERP_CTS_PROT |
353 BSS_CHANGED_ERP_PREAMBLE |
354 BSS_CHANGED_ERP_SLOT;
352} 355}
353 356
354void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, 357void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 6ad2619db85f..829995e740a7 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -568,15 +568,27 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
568 } 568 }
569} 569}
570 570
571static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata, 571static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
572 bool use_protection, 572 u16 capab, bool erp_valid, u8 erp)
573 bool use_short_preamble)
574{ 573{
575 struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; 574 struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf;
576#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 575#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
577 struct ieee80211_if_sta *ifsta = &sdata->u.sta; 576 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
578#endif 577#endif
579 u32 changed = 0; 578 u32 changed = 0;
579 bool use_protection;
580 bool use_short_preamble;
581 bool use_short_slot;
582
583 if (erp_valid) {
584 use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
585 use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
586 } else {
587 use_protection = false;
588 use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
589 }
590
591 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
580 592
581 if (use_protection != bss_conf->use_cts_prot) { 593 if (use_protection != bss_conf->use_cts_prot) {
582#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 594#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
@@ -605,30 +617,18 @@ static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata,
605 changed |= BSS_CHANGED_ERP_PREAMBLE; 617 changed |= BSS_CHANGED_ERP_PREAMBLE;
606 } 618 }
607 619
608 return changed; 620 if (use_short_slot != bss_conf->use_short_slot) {
609} 621#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
610 622 if (net_ratelimit()) {
611static u32 ieee80211_handle_erp_ie(struct ieee80211_sub_if_data *sdata, 623 printk(KERN_DEBUG "%s: switched to %s slot"
612 u8 erp_value) 624 " (BSSID=%s)\n",
613{ 625 sdata->dev->name,
614 bool use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0; 626 use_short_slot ? "short" : "long",
615 bool use_short_preamble = (erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0; 627 ifsta->bssid);
616 628 }
617 return ieee80211_handle_protect_preamb(sdata, 629#endif
618 use_protection, use_short_preamble); 630 bss_conf->use_short_slot = use_short_slot;
619} 631 changed |= BSS_CHANGED_ERP_SLOT;
620
621static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
622 struct ieee80211_bss *bss)
623{
624 u32 changed = 0;
625
626 if (bss->has_erp_value)
627 changed |= ieee80211_handle_erp_ie(sdata, bss->erp_value);
628 else {
629 u16 capab = bss->capability;
630 changed |= ieee80211_handle_protect_preamb(sdata, false,
631 (capab & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0);
632 } 632 }
633 633
634 return changed; 634 return changed;
@@ -721,7 +721,8 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
721 sdata->bss_conf.timestamp = bss->timestamp; 721 sdata->bss_conf.timestamp = bss->timestamp;
722 sdata->bss_conf.dtim_period = bss->dtim_period; 722 sdata->bss_conf.dtim_period = bss->dtim_period;
723 723
724 changed |= ieee80211_handle_bss_capability(sdata, bss); 724 changed |= ieee80211_handle_bss_capability(sdata,
725 bss->capability, bss->has_erp_value, bss->erp_value);
725 726
726 ieee80211_rx_bss_put(local, bss); 727 ieee80211_rx_bss_put(local, bss);
727 } 728 }
@@ -1657,6 +1658,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1657 struct ieee80211_local *local = sdata->local; 1658 struct ieee80211_local *local = sdata->local;
1658 struct ieee80211_conf *conf = &local->hw.conf; 1659 struct ieee80211_conf *conf = &local->hw.conf;
1659 u32 changed = 0; 1660 u32 changed = 0;
1661 bool erp_valid;
1662 u8 erp_value = 0;
1660 1663
1661 /* Process beacon from the current BSS */ 1664 /* Process beacon from the current BSS */
1662 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; 1665 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
@@ -1678,13 +1681,16 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1678 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param, 1681 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param,
1679 elems.wmm_param_len); 1682 elems.wmm_param_len);
1680 1683
1681 if (elems.erp_info && elems.erp_info_len >= 1) 1684
1682 changed |= ieee80211_handle_erp_ie(sdata, elems.erp_info[0]); 1685 if (elems.erp_info && elems.erp_info_len >= 1) {
1683 else { 1686 erp_valid = true;
1684 u16 capab = le16_to_cpu(mgmt->u.beacon.capab_info); 1687 erp_value = elems.erp_info[0];
1685 changed |= ieee80211_handle_protect_preamb(sdata, false, 1688 } else {
1686 (capab & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0); 1689 erp_valid = false;
1687 } 1690 }
1691 changed |= ieee80211_handle_bss_capability(sdata,
1692 le16_to_cpu(mgmt->u.beacon.capab_info),
1693 erp_valid, erp_value);
1688 1694
1689 if (elems.ht_cap_elem && elems.ht_info_elem && 1695 if (elems.ht_cap_elem && elems.ht_info_elem &&
1690 elems.wmm_param && conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) { 1696 elems.wmm_param && conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {