1 Subject: mac80211: fix short slot handling
3 This patch makes mac80211 handle short slot requests from the AP
4 properly. Also warn about uses of IEEE80211_CONF_SHORT_SLOT_TIME
5 and optimise out the code since it cannot ever be hit anyway.
7 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
9 include/net/mac80211.h | 28 ++++++++++--------
10 net/mac80211/main.c | 9 +++--
11 net/mac80211/mlme.c | 74 ++++++++++++++++++++++++++-----------------------
12 3 files changed, 62 insertions(+), 49 deletions(-)
14 --- everything.orig/net/mac80211/main.c 2008-10-07 20:06:43.000000000 +0200
15 +++ everything/net/mac80211/main.c 2008-10-08 10:56:29.000000000 +0200
16 @@ -346,9 +346,12 @@ void ieee80211_bss_info_change_notify(st
18 u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata)
20 - sdata->bss_conf.use_cts_prot = 0;
21 - sdata->bss_conf.use_short_preamble = 0;
22 - return BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_ERP_PREAMBLE;
23 + sdata->bss_conf.use_cts_prot = false;
24 + sdata->bss_conf.use_short_preamble = false;
25 + sdata->bss_conf.use_short_slot = false;
26 + return BSS_CHANGED_ERP_CTS_PROT |
27 + BSS_CHANGED_ERP_PREAMBLE |
28 + BSS_CHANGED_ERP_SLOT;
31 void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
32 --- everything.orig/net/mac80211/mlme.c 2008-10-07 20:05:49.000000000 +0200
33 +++ everything/net/mac80211/mlme.c 2008-10-08 10:56:38.000000000 +0200
34 @@ -568,9 +568,8 @@ static void ieee80211_sta_wmm_params(str
38 -static u32 ieee80211_handle_protect_preamb(struct ieee80211_sub_if_data *sdata,
39 - bool use_protection,
40 - bool use_short_preamble)
41 +static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
42 + u16 capab, bool erp_valid, u8 erp)
44 struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf;
45 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
46 @@ -578,6 +577,19 @@ static u32 ieee80211_handle_protect_prea
50 + bool use_protection;
51 + bool use_short_preamble;
52 + bool use_short_slot;
55 + use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
56 + use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
58 + use_protection = false;
59 + use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
62 + use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
64 if (use_protection != bss_conf->use_cts_prot) {
65 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
66 @@ -607,30 +619,18 @@ static u32 ieee80211_handle_protect_prea
67 changed |= BSS_CHANGED_ERP_PREAMBLE;
73 -static u32 ieee80211_handle_erp_ie(struct ieee80211_sub_if_data *sdata,
76 - bool use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0;
77 - bool use_short_preamble = (erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0;
79 - return ieee80211_handle_protect_preamb(sdata,
80 - use_protection, use_short_preamble);
83 -static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
84 - struct ieee80211_bss *bss)
88 - if (bss->has_erp_value)
89 - changed |= ieee80211_handle_erp_ie(sdata, bss->erp_value);
91 - u16 capab = bss->capability;
92 - changed |= ieee80211_handle_protect_preamb(sdata, false,
93 - (capab & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0);
94 + if (use_short_slot != bss_conf->use_short_slot) {
95 +#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
96 + if (net_ratelimit()) {
97 + printk(KERN_DEBUG "%s: switched to %s slot"
100 + use_short_slot ? "short" : "long",
101 + print_mac(mac, ifsta->bssid));
104 + bss_conf->use_short_slot = use_short_slot;
105 + changed |= BSS_CHANGED_ERP_SLOT;
109 @@ -723,7 +723,8 @@ static void ieee80211_set_associated(str
110 sdata->bss_conf.timestamp = bss->timestamp;
111 sdata->bss_conf.dtim_period = bss->dtim_period;
113 - changed |= ieee80211_handle_bss_capability(sdata, bss);
114 + changed |= ieee80211_handle_bss_capability(sdata,
115 + bss->capability, bss->has_erp_value, bss->erp_value);
117 ieee80211_rx_bss_put(local, bss);
119 @@ -1675,6 +1676,8 @@ static void ieee80211_rx_mgmt_beacon(str
120 struct ieee80211_local *local = sdata->local;
121 struct ieee80211_conf *conf = &local->hw.conf;
126 /* Process beacon from the current BSS */
127 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
128 @@ -1696,13 +1699,16 @@ static void ieee80211_rx_mgmt_beacon(str
129 ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param,
130 elems.wmm_param_len);
132 - if (elems.erp_info && elems.erp_info_len >= 1)
133 - changed |= ieee80211_handle_erp_ie(sdata, elems.erp_info[0]);
135 - u16 capab = le16_to_cpu(mgmt->u.beacon.capab_info);
136 - changed |= ieee80211_handle_protect_preamb(sdata, false,
137 - (capab & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0);
139 + if (elems.erp_info && elems.erp_info_len >= 1) {
141 + erp_value = elems.erp_info[0];
145 + changed |= ieee80211_handle_bss_capability(sdata,
146 + le16_to_cpu(mgmt->u.beacon.capab_info),
147 + erp_valid, erp_value);
149 if (elems.ht_cap_elem && elems.ht_info_elem &&
150 elems.wmm_param && conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
151 --- everything.orig/include/net/mac80211.h 2008-10-07 20:06:43.000000000 +0200
152 +++ everything/include/net/mac80211.h 2008-10-08 10:57:06.000000000 +0200
153 @@ -180,8 +180,12 @@ enum ieee80211_bss_change {
154 * @assoc: association status
155 * @aid: association ID number, valid only when @assoc is true
156 * @use_cts_prot: use CTS protection
157 - * @use_short_preamble: use 802.11b short preamble
158 - * @use_short_slot: use short slot time (only relevant for ERP)
159 + * @use_short_preamble: use 802.11b short preamble;
160 + * if the hardware cannot handle this it must set the
161 + * IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag
162 + * @use_short_slot: use short slot time (only relevant for ERP);
163 + * if the hardware cannot handle this it must set the
164 + * IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag
165 * @dtim_period: num of beacons before the next DTIM, for PSM
166 * @timestamp: beacon timestamp
167 * @beacon_int: beacon interval
168 @@ -442,23 +446,23 @@ struct ieee80211_rx_status {
170 * Flags to define PHY configuration options
172 - * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
173 * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
174 * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported)
175 * @IEEE80211_CONF_PS: Enable 802.11 power save mode
177 enum ieee80211_conf_flags {
179 - * TODO: IEEE80211_CONF_SHORT_SLOT_TIME will be removed once drivers
180 - * have been converted to use bss_info_changed() for slot time
183 - IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0),
184 - IEEE80211_CONF_RADIOTAP = (1<<1),
185 - IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2),
186 - IEEE80211_CONF_PS = (1<<3),
187 + IEEE80211_CONF_RADIOTAP = (1<<0),
188 + IEEE80211_CONF_SUPPORT_HT_MODE = (1<<1),
189 + IEEE80211_CONF_PS = (1<<2),
192 +/* XXX: remove all this once drivers stop trying to use it */
193 +static inline int __deprecated __IEEE80211_CONF_SHORT_SLOT_TIME(void)
197 +#define IEEE80211_CONF_SHORT_SLOT_TIME (__IEEE80211_CONF_SHORT_SLOT_TIME())
200 * struct ieee80211_conf - configuration of the device