Enable more PCMCIA specific options, thanks sn9
[librecmc/librecmc.git] / package / mac80211 / patches / 414-mac80211-slot-time.patch
1 Subject: mac80211: fix short slot handling
2
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.
6
7 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
8 ---
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(-)
13
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
17  
18  u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata)
19  {
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;
29  }
30  
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
35         }
36  }
37  
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)
43  {
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
47         DECLARE_MAC_BUF(mac);
48  #endif
49         u32 changed = 0;
50 +       bool use_protection;
51 +       bool use_short_preamble;
52 +       bool use_short_slot;
53 +
54 +       if (erp_valid) {
55 +               use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
56 +               use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
57 +       } else {
58 +               use_protection = false;
59 +               use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
60 +       }
61 +
62 +       use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
63  
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;
68         }
69  
70 -       return changed;
71 -}
72 -
73 -static u32 ieee80211_handle_erp_ie(struct ieee80211_sub_if_data *sdata,
74 -                                  u8 erp_value)
75 -{
76 -       bool use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0;
77 -       bool use_short_preamble = (erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0;
78 -
79 -       return ieee80211_handle_protect_preamb(sdata,
80 -                       use_protection, use_short_preamble);
81 -}
82 -
83 -static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
84 -                                          struct ieee80211_bss *bss)
85 -{
86 -       u32 changed = 0;
87 -
88 -       if (bss->has_erp_value)
89 -               changed |= ieee80211_handle_erp_ie(sdata, bss->erp_value);
90 -       else {
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"
98 +                              " (BSSID=%s)\n",
99 +                              sdata->dev->name,
100 +                              use_short_slot ? "short" : "long",
101 +                              print_mac(mac, ifsta->bssid));
102 +               }
103 +#endif
104 +               bss_conf->use_short_slot = use_short_slot;
105 +               changed |= BSS_CHANGED_ERP_SLOT;
106         }
107  
108         return changed;
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;
112  
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);
116  
117                 ieee80211_rx_bss_put(local, bss);
118         }
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;
122         u32 changed = 0;
123 +       bool erp_valid;
124 +       u8 erp_value = 0;
125  
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);
131  
132 -       if (elems.erp_info && elems.erp_info_len >= 1)
133 -               changed |= ieee80211_handle_erp_ie(sdata, elems.erp_info[0]);
134 -       else {
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);
138 +
139 +       if (elems.erp_info && elems.erp_info_len >= 1) {
140 +               erp_valid = true;
141 +               erp_value = elems.erp_info[0];
142 +       } else {
143 +               erp_valid = false;
144         }
145 +       changed |= ieee80211_handle_bss_capability(sdata,
146 +                       le16_to_cpu(mgmt->u.beacon.capab_info),
147 +                       erp_valid, erp_value);
148  
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 {
169   *
170   * Flags to define PHY configuration options
171   *
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
176   */
177  enum ieee80211_conf_flags {
178 -       /*
179 -        * TODO: IEEE80211_CONF_SHORT_SLOT_TIME will be removed once drivers
180 -        * have been converted to use bss_info_changed() for slot time
181 -        * configuration
182 -        */
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),
190  };
191  
192 +/* XXX: remove all this once drivers stop trying to use it */
193 +static inline int __deprecated __IEEE80211_CONF_SHORT_SLOT_TIME(void)
194 +{
195 +       return 0;
196 +}
197 +#define IEEE80211_CONF_SHORT_SLOT_TIME (__IEEE80211_CONF_SHORT_SLOT_TIME())
198 +
199  /**
200   * struct ieee80211_conf - configuration of the device
201   *