Enable more PCMCIA specific options, thanks sn9
[openwrt.git] / package / mac80211 / patches / 425-rewrite-rate-api.patch
1 Subject: mac80211/drivers: rewrite the rate control API
2
3 So after the previous changes we were still unhappy with how
4 convoluted the API is and decided to make things simpler for
5 everybody. This completely changes the rate control API, now
6 taking into account 802.11n with MCS rates and more control,
7 most drivers don't support that though.
8
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
11 ---
12 drivers/net/wireless/adm8211.c | 21 -
13 drivers/net/wireless/ath5k/base.c | 34 +-
14 drivers/net/wireless/ath9k/main.c | 18 -
15 drivers/net/wireless/ath9k/rc.c | 40 +--
16 drivers/net/wireless/ath9k/xmit.c | 28 +-
17 drivers/net/wireless/b43/dma.c | 4
18 drivers/net/wireless/b43/main.c | 2
19 drivers/net/wireless/b43/pio.c | 4
20 drivers/net/wireless/b43/xmit.c | 60 +++-
21 drivers/net/wireless/b43/xmit.h | 5
22 drivers/net/wireless/b43legacy/dma.c | 46 ++-
23 drivers/net/wireless/b43legacy/main.c | 2
24 drivers/net/wireless/b43legacy/pio.c | 31 ++
25 drivers/net/wireless/b43legacy/xmit.c | 26 +-
26 drivers/net/wireless/b43legacy/xmit.h | 2
27 drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 57 +---
28 drivers/net/wireless/iwlwifi/iwl-3945.c | 62 ++++-
29 drivers/net/wireless/iwlwifi/iwl-3945.h | 2
30 drivers/net/wireless/iwlwifi/iwl-4965.c | 8
31 drivers/net/wireless/iwlwifi/iwl-5000.c | 8
32 drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 37 +-
33 drivers/net/wireless/iwlwifi/iwl-core.c | 19 -
34 drivers/net/wireless/iwlwifi/iwl3945-base.c | 5
35 drivers/net/wireless/libertas_tf/main.c | 4
36 drivers/net/wireless/mac80211_hwsim.c | 12
37 drivers/net/wireless/p54/p54common.c | 16 -
38 drivers/net/wireless/rt2x00/rt2x00dev.c | 11
39 drivers/net/wireless/rt2x00/rt2x00mac.c | 14 -
40 drivers/net/wireless/rt2x00/rt2x00queue.c | 11
41 drivers/net/wireless/rtl8180_dev.c | 28 +-
42 drivers/net/wireless/rtl8187_dev.c | 10
43 drivers/net/wireless/zd1211rw/zd_mac.c | 28 +-
44 include/net/mac80211.h | 206 +++++++++-------
45 net/mac80211/ieee80211_i.h | 8
46 net/mac80211/main.c | 54 +++-
47 net/mac80211/mesh_hwmp.c | 6
48 net/mac80211/rate.c | 50 +---
49 net/mac80211/rate.h | 5
50 net/mac80211/rc80211_minstrel.c | 72 ++---
51 net/mac80211/rc80211_pid.h | 1
52 net/mac80211/rc80211_pid_algo.c | 26 +-
53 net/mac80211/rc80211_pid_debugfs.c | 5
54 net/mac80211/sta_info.h | 4
55 net/mac80211/tx.c | 347 +++++++++++-----------------
56 net/mac80211/wext.c | 4
57 45 files changed, 781 insertions(+), 662 deletions(-)
58
59 --- a/include/net/mac80211.h
60 +++ b/include/net/mac80211.h
61 @@ -222,29 +222,24 @@ struct ieee80211_bss_conf {
62 * These flags are used with the @flags member of &ieee80211_tx_info.
63 *
64 * @IEEE80211_TX_CTL_REQ_TX_STATUS: request TX status callback for this frame.
65 - * @IEEE80211_TX_CTL_USE_RTS_CTS: use RTS-CTS before sending frame
66 - * @IEEE80211_TX_CTL_USE_CTS_PROTECT: use CTS protection for the frame (e.g.,
67 - * for combined 802.11g / 802.11b networks)
68 + * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
69 + * number to this frame, taking care of not overwriting the fragment
70 + * number and increasing the sequence number only when the
71 + * IEEE80211_TX_CTL_FIRST_FRAGMENT flags is set. mac80211 will properly
72 + * assign sequence numbers to QoS-data frames but cannot do so correctly
73 + * for non-QoS-data and management frames because beacons need them from
74 + * that counter as well and mac80211 cannot guarantee proper sequencing.
75 + * If this flag is set, the driver should instruct the hardware to
76 + * assign a sequence number to the frame or assign one itself. Cf. IEEE
77 + * 802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
78 + * beacons always be clear for frames without a sequence number field.
79 * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack
80 - * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: TBD
81 * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination
82 * station
83 - * @IEEE80211_TX_CTL_REQUEUE: TBD
84 * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame
85 - * @IEEE80211_TX_CTL_SHORT_PREAMBLE: TBD
86 - * @IEEE80211_TX_CTL_LONG_RETRY_LIMIT: this frame should be send using the
87 - * through set_retry_limit configured long retry value
88 * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
89 * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU
90 - * @IEEE80211_TX_CTL_OFDM_HT: this frame can be sent in HT OFDM rates. number
91 - * of streams when this flag is on can be extracted from antenna_sel_tx,
92 - * so if 1 antenna is marked use SISO, 2 antennas marked use MIMO, n
93 - * antennas marked use MIMO_n.
94 - * @IEEE80211_TX_CTL_GREEN_FIELD: use green field protection for this frame
95 - * @IEEE80211_TX_CTL_40_MHZ_WIDTH: send this frame using 40 Mhz channel width
96 - * @IEEE80211_TX_CTL_DUP_DATA: duplicate data frame on both 20 Mhz channels
97 - * @IEEE80211_TX_CTL_SHORT_GI: send this frame using short guard interval
98 - * @IEEE80211_TX_CTL_INJECTED: TBD
99 + * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211.
100 * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted
101 * because the destination STA was in powersave mode.
102 * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
103 @@ -252,42 +247,41 @@ struct ieee80211_bss_conf {
104 * is for the whole aggregation.
105 * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
106 * so consider using block ack request (BAR).
107 - * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
108 - * number to this frame, taking care of not overwriting the fragment
109 - * number and increasing the sequence number only when the
110 - * IEEE80211_TX_CTL_FIRST_FRAGMENT flags is set. mac80211 will properly
111 - * assign sequence numbers to QoS-data frames but cannot do so correctly
112 - * for non-QoS-data and management frames because beacons need them from
113 - * that counter as well and mac80211 cannot guarantee proper sequencing.
114 - * If this flag is set, the driver should instruct the hardware to
115 - * assign a sequence number to the frame or assign one itself. Cf. IEEE
116 - * 802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
117 - * beacons always be clear for frames without a sequence number field.
118 + * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
119 + * set by rate control algorithms to indicate probe rate, will
120 + * be cleared for fragmented frames (except on the last fragment)
121 + * @IEEE80211_TX_CTL_REQUEUE: REMOVE THIS
122 */
123 enum mac80211_tx_control_flags {
124 IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0),
125 - IEEE80211_TX_CTL_USE_RTS_CTS = BIT(2),
126 - IEEE80211_TX_CTL_USE_CTS_PROTECT = BIT(3),
127 - IEEE80211_TX_CTL_NO_ACK = BIT(4),
128 - IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(5),
129 - IEEE80211_TX_CTL_CLEAR_PS_FILT = BIT(6),
130 - IEEE80211_TX_CTL_REQUEUE = BIT(7),
131 - IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(8),
132 - IEEE80211_TX_CTL_SHORT_PREAMBLE = BIT(9),
133 - IEEE80211_TX_CTL_LONG_RETRY_LIMIT = BIT(10),
134 - IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(12),
135 - IEEE80211_TX_CTL_AMPDU = BIT(13),
136 - IEEE80211_TX_CTL_OFDM_HT = BIT(14),
137 - IEEE80211_TX_CTL_GREEN_FIELD = BIT(15),
138 - IEEE80211_TX_CTL_40_MHZ_WIDTH = BIT(16),
139 - IEEE80211_TX_CTL_DUP_DATA = BIT(17),
140 - IEEE80211_TX_CTL_SHORT_GI = BIT(18),
141 - IEEE80211_TX_CTL_INJECTED = BIT(19),
142 - IEEE80211_TX_STAT_TX_FILTERED = BIT(20),
143 - IEEE80211_TX_STAT_ACK = BIT(21),
144 - IEEE80211_TX_STAT_AMPDU = BIT(22),
145 - IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(23),
146 - IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(24),
147 + IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(1),
148 + IEEE80211_TX_CTL_NO_ACK = BIT(2),
149 + IEEE80211_TX_CTL_CLEAR_PS_FILT = BIT(3),
150 + IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(4),
151 + IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(5),
152 + IEEE80211_TX_CTL_AMPDU = BIT(6),
153 + IEEE80211_TX_CTL_INJECTED = BIT(7),
154 + IEEE80211_TX_STAT_TX_FILTERED = BIT(8),
155 + IEEE80211_TX_STAT_ACK = BIT(9),
156 + IEEE80211_TX_STAT_AMPDU = BIT(10),
157 + IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(11),
158 + IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(12),
159 +
160 + /* XXX: remove this */
161 + IEEE80211_TX_CTL_REQUEUE = BIT(13),
162 +};
163 +
164 +enum mac80211_rate_control_flags {
165 + IEEE80211_TX_RC_USE_RTS_CTS = BIT(0),
166 + IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1),
167 + IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
168 +
169 + /* rate index is an MCS rate number instead of an index */
170 + IEEE80211_TX_RC_MCS = BIT(3),
171 + IEEE80211_TX_RC_GREEN_FIELD = BIT(4),
172 + IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5),
173 + IEEE80211_TX_RC_DUP_DATA = BIT(6),
174 + IEEE80211_TX_RC_SHORT_GI = BIT(7),
175 };
176
177
178 @@ -296,18 +290,26 @@ enum mac80211_tx_control_flags {
179 #define IEEE80211_TX_INFO_DRIVER_DATA_PTRS \
180 (IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *))
181
182 -/* maximum number of alternate rate retry stages */
183 -#define IEEE80211_TX_MAX_ALTRATE 3
184 +/* maximum number of rate stages */
185 +#define IEEE80211_TX_MAX_RATES 4
186
187 /**
188 - * struct ieee80211_tx_altrate - alternate rate selection/status
189 + * struct ieee80211_tx_rate - rate selection/status
190 *
191 - * @rate_idx: rate index to attempt to send with
192 + * @idx: rate index to attempt to send with
193 + * @flags: rate control flags (&enum mac80211_rate_control_flags)
194 * @limit: number of retries before fallback
195 + *
196 + * A value of -1 for @idx indicates an invalid rate and, if used
197 + * in an array of retry rates, that no more rates should be tried.
198 + *
199 + * When used for transmit status reporting, the driver should
200 + * always report the rate along with the flags it used.
201 */
202 -struct ieee80211_tx_altrate {
203 - s8 rate_idx;
204 - u8 limit;
205 +struct ieee80211_tx_rate {
206 + s8 idx;
207 + u8 count;
208 + u8 flags;
209 };
210
211 /**
212 @@ -322,15 +324,12 @@ struct ieee80211_tx_altrate {
213 * it may be NULL.
214 *
215 * @flags: transmit info flags, defined above
216 - * @band: TBD
217 - * @tx_rate_idx: TBD
218 + * @band: the band to transmit on (use for checking for races)
219 * @antenna_sel_tx: antenna to use, 0 for automatic diversity
220 * @control: union for control data
221 * @status: union for status data
222 * @driver_data: array of driver_data pointers
223 * @retry_count: number of retries
224 - * @excessive_retries: set to 1 if the frame was retried many times
225 - * but not acknowledged
226 * @ampdu_ack_len: number of aggregated frames.
227 * relevant only if IEEE80211_TX_STATUS_AMPDU was set.
228 * @ampdu_ack_map: block ack bit map for the aggregation.
229 @@ -341,28 +340,28 @@ struct ieee80211_tx_info {
230 /* common information */
231 u32 flags;
232 u8 band;
233 - s8 tx_rate_idx;
234 +
235 u8 antenna_sel_tx;
236
237 - /* 1 byte hole */
238 + /* 2 byte hole */
239
240 union {
241 struct {
242 + union {
243 + struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
244 + /* we need the jiffies only before rate control */
245 + unsigned long jiffies;
246 + };
247 + s8 rts_cts_rate_idx;
248 /* NB: vif can be NULL for injected frames */
249 struct ieee80211_vif *vif;
250 struct ieee80211_key_conf *hw_key;
251 struct ieee80211_sta *sta;
252 - unsigned long jiffies;
253 - s8 rts_cts_rate_idx;
254 - u8 retry_limit;
255 - struct ieee80211_tx_altrate retries[IEEE80211_TX_MAX_ALTRATE];
256 } control;
257 struct {
258 + struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
259 u64 ampdu_ack_map;
260 int ack_signal;
261 - struct ieee80211_tx_altrate retries[IEEE80211_TX_MAX_ALTRATE + 1];
262 - u8 retry_count;
263 - bool excessive_retries;
264 u8 ampdu_ack_len;
265 } status;
266 void *driver_data[IEEE80211_TX_INFO_DRIVER_DATA_PTRS];
267 @@ -374,6 +373,22 @@ static inline struct ieee80211_tx_info *
268 return (struct ieee80211_tx_info *)skb->cb;
269 }
270
271 +static inline void
272 +ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
273 +{
274 + int i;
275 +
276 + BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
277 + offsetof(struct ieee80211_tx_info, control.rates));
278 + /* clear the rate counts */
279 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
280 + info->status.rates[i].count = 0;
281 +
282 + memset(&info->status.ampdu_ack_map, 0,
283 + sizeof(struct ieee80211_tx_info) -
284 + offsetof(struct ieee80211_tx_info, status.ampdu_ack_map));
285 +}
286 +
287
288 /**
289 * enum mac80211_rx_flags - receive flags
290 @@ -875,8 +890,8 @@ enum ieee80211_hw_flags {
291 * @sta_data_size: size (in bytes) of the drv_priv data area
292 * within &struct ieee80211_sta.
293 *
294 - * @max_altrates: maximum number of alternate rate retry stages
295 - * @max_altrate_tries: maximum number of tries for each stage
296 + * @max_rates: maximum number of alternate rate retry stages
297 + * @max_rate_tries: maximum number of tries for each stage
298 */
299 struct ieee80211_hw {
300 struct ieee80211_conf conf;
301 @@ -893,8 +908,8 @@ struct ieee80211_hw {
302 u16 ampdu_queues;
303 u16 max_listen_interval;
304 s8 max_signal;
305 - u8 max_altrates;
306 - u8 max_altrate_tries;
307 + u8 max_rates;
308 + u8 max_rate_tries;
309 };
310
311 /**
312 @@ -933,9 +948,9 @@ static inline struct ieee80211_rate *
313 ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
314 const struct ieee80211_tx_info *c)
315 {
316 - if (WARN_ON(c->tx_rate_idx < 0))
317 + if (WARN_ON(c->control.rates[0].idx < 0))
318 return NULL;
319 - return &hw->wiphy->bands[c->band]->bitrates[c->tx_rate_idx];
320 + return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
321 }
322
323 static inline struct ieee80211_rate *
324 @@ -951,9 +966,9 @@ static inline struct ieee80211_rate *
325 ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
326 const struct ieee80211_tx_info *c, int idx)
327 {
328 - if (c->control.retries[idx].rate_idx < 0)
329 + if (c->control.rates[idx + 1].idx < 0)
330 return NULL;
331 - return &hw->wiphy->bands[c->band]->bitrates[c->control.retries[idx].rate_idx];
332 + return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx];
333 }
334
335 /**
336 @@ -1847,17 +1862,28 @@ struct ieee80211_sta *ieee80211_find_sta
337
338
339 /* Rate control API */
340 +
341 /**
342 - * struct rate_selection - rate information for/from rate control algorithms
343 + * struct ieee80211_tx_rate_control - rate control information for/from RC algo
344 *
345 - * @rate_idx: selected transmission rate index
346 - * @nonerp_idx: Non-ERP rate to use instead if ERP cannot be used
347 - * @probe_idx: rate for probing (or -1)
348 - * @max_rate_idx: maximum rate index that can be used, this is
349 - * input to the algorithm and will be enforced
350 - */
351 -struct rate_selection {
352 - s8 rate_idx, nonerp_idx, probe_idx, max_rate_idx;
353 + * @sband: The band this frame is being transmitted on.
354 + * @bss_conf: the current BSS configuration
355 + * @reported_rate: The rate control algorithm can fill this in to indicate
356 + * which rate should be reported to userspace as the current rate and
357 + * used for rate calculations in the mesh network.
358 + * @rts: whether RTS will be used for this frame because it is longer than the
359 + * RTS threshold
360 + * @short_preamble: whether mac80211 will request short-preamble transmission
361 + * if the selected rate supports it
362 + * @max_rate_idx: user-requested maximum rate (not MCS for now)
363 + */
364 +struct ieee80211_tx_rate_control {
365 + struct ieee80211_supported_band *sband;
366 + struct ieee80211_bss_conf *bss_conf;
367 + struct sk_buff *skb;
368 + struct ieee80211_tx_rate reported_rate;
369 + bool rts, short_preamble;
370 + u8 max_rate_idx;
371 };
372
373 struct rate_control_ops {
374 @@ -1876,10 +1902,8 @@ struct rate_control_ops {
375 void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
376 struct ieee80211_sta *sta, void *priv_sta,
377 struct sk_buff *skb);
378 - void (*get_rate)(void *priv, struct ieee80211_supported_band *sband,
379 - struct ieee80211_sta *sta, void *priv_sta,
380 - struct sk_buff *skb,
381 - struct rate_selection *sel);
382 + void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta,
383 + struct ieee80211_tx_rate_control *txrc);
384
385 void (*add_sta_debugfs)(void *priv, void *priv_sta,
386 struct dentry *dir);
387 --- a/net/mac80211/main.c
388 +++ b/net/mac80211/main.c
389 @@ -41,6 +41,8 @@
390 */
391 struct ieee80211_tx_status_rtap_hdr {
392 struct ieee80211_radiotap_header hdr;
393 + u8 rate;
394 + u8 padding_for_rate;
395 __le16 tx_flags;
396 u8 data_retries;
397 } __attribute__ ((packed));
398 @@ -463,13 +465,28 @@ void ieee80211_tx_status(struct ieee8021
399 struct ieee80211_sub_if_data *sdata;
400 struct net_device *prev_dev = NULL;
401 struct sta_info *sta;
402 + int retry_count = -1, i;
403 +
404 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
405 + /* the HW cannot have attempted that rate */
406 + if (i >= hw->max_rates) {
407 + info->status.rates[i].idx = -1;
408 + info->status.rates[i].count = 0;
409 + }
410 +
411 + retry_count += info->status.rates[i].count;
412 + }
413 + if (retry_count < 0)
414 + retry_count = 0;
415
416 rcu_read_lock();
417
418 + sband = local->hw.wiphy->bands[info->band];
419 +
420 sta = sta_info_get(local, hdr->addr1);
421
422 if (sta) {
423 - if (info->status.excessive_retries &&
424 + if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
425 test_sta_flags(sta, WLAN_STA_PS)) {
426 /*
427 * The STA is in power save mode, so assume
428 @@ -500,12 +517,11 @@ void ieee80211_tx_status(struct ieee8021
429 rcu_read_unlock();
430 return;
431 } else {
432 - if (info->status.excessive_retries)
433 + if (!(info->flags & IEEE80211_TX_STAT_ACK))
434 sta->tx_retry_failed++;
435 - sta->tx_retry_count += info->status.retry_count;
436 + sta->tx_retry_count += retry_count;
437 }
438
439 - sband = local->hw.wiphy->bands[info->band];
440 rate_control_tx_status(local, sband, sta, skb);
441 }
442
443 @@ -526,9 +542,9 @@ void ieee80211_tx_status(struct ieee8021
444 local->dot11TransmittedFrameCount++;
445 if (is_multicast_ether_addr(hdr->addr1))
446 local->dot11MulticastTransmittedFrameCount++;
447 - if (info->status.retry_count > 0)
448 + if (retry_count > 0)
449 local->dot11RetryCount++;
450 - if (info->status.retry_count > 1)
451 + if (retry_count > 1)
452 local->dot11MultipleRetryCount++;
453 }
454
455 @@ -572,19 +588,30 @@ void ieee80211_tx_status(struct ieee8021
456 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
457 rthdr->hdr.it_present =
458 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
459 - (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
460 + (1 << IEEE80211_RADIOTAP_DATA_RETRIES) |
461 + (1 << IEEE80211_RADIOTAP_RATE));
462
463 if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
464 !is_multicast_ether_addr(hdr->addr1))
465 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
466
467 - if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) &&
468 - (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT))
469 + /*
470 + * XXX: Once radiotap gets the bitmap reset thing the vendor
471 + * extensions proposal contains, we can actually report
472 + * the whole set of tries we did.
473 + */
474 + if ((info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
475 + (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
476 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
477 - else if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
478 + else if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
479 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
480 + if (info->status.rates[0].idx >= 0 &&
481 + !(info->status.rates[0].flags & IEEE80211_TX_RC_MCS))
482 + rthdr->rate = sband->bitrates[
483 + info->status.rates[0].idx].bitrate / 5;
484
485 - rthdr->data_retries = info->status.retry_count;
486 + /* for now report the total retry_count */
487 + rthdr->data_retries = retry_count;
488
489 /* XXX: is this sufficient for BPF? */
490 skb_set_mac_header(skb, 0);
491 @@ -669,8 +696,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(
492 BUG_ON(!ops->configure_filter);
493 local->ops = ops;
494
495 - local->hw.queues = 1; /* default */
496 -
497 + /* set up some defaults */
498 + local->hw.queues = 1;
499 + local->hw.max_rates = 1;
500 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
501 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
502 local->hw.conf.long_frame_max_tx_count = 4;
503 --- a/net/mac80211/tx.c
504 +++ b/net/mac80211/tx.c
505 @@ -46,13 +46,20 @@ static __le16 ieee80211_duration(struct
506 struct ieee80211_local *local = tx->local;
507 struct ieee80211_supported_band *sband;
508 struct ieee80211_hdr *hdr;
509 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
510 +
511 + /* assume HW handles this */
512 + if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
513 + return 0;
514 +
515 + /* uh huh? */
516 + if (WARN_ON(info->control.rates[0].idx < 0))
517 + return 0;
518
519 sband = local->hw.wiphy->bands[tx->channel->band];
520 - txrate = &sband->bitrates[tx->rate_idx];
521 + txrate = &sband->bitrates[info->control.rates[0].idx];
522
523 - erp = 0;
524 - if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
525 - erp = txrate->flags & IEEE80211_RATE_ERP_G;
526 + erp = txrate->flags & IEEE80211_RATE_ERP_G;
527
528 /*
529 * data and mgmt (except PS Poll):
530 @@ -439,140 +446,123 @@ ieee80211_tx_h_select_key(struct ieee802
531 static ieee80211_tx_result debug_noinline
532 ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
533 {
534 - struct rate_selection rsel;
535 - struct ieee80211_supported_band *sband;
536 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
537 + struct ieee80211_hdr *hdr = (void *)tx->skb->data;
538 + struct ieee80211_supported_band *sband;
539 + struct ieee80211_rate *rate;
540 + int i, len;
541 + bool inval = false, rts = false, short_preamble = false;
542 + struct ieee80211_tx_rate_control txrc;
543
544 - sband = tx->local->hw.wiphy->bands[tx->channel->band];
545 + memset(&txrc, 0, sizeof(txrc));
546
547 - if (likely(tx->rate_idx < 0)) {
548 - rate_control_get_rate(tx->sdata, sband, tx->sta,
549 - tx->skb, &rsel);
550 - if (tx->sta)
551 - tx->sta->last_txrate_idx = rsel.rate_idx;
552 - tx->rate_idx = rsel.rate_idx;
553 - if (unlikely(rsel.probe_idx >= 0)) {
554 - info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
555 - tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
556 - info->control.retries[0].rate_idx = tx->rate_idx;
557 - info->control.retries[0].limit = tx->local->hw.max_altrate_tries;
558 - tx->rate_idx = rsel.probe_idx;
559 - } else if (info->control.retries[0].limit == 0)
560 - info->control.retries[0].rate_idx = -1;
561 + sband = tx->local->hw.wiphy->bands[tx->channel->band];
562
563 - if (unlikely(tx->rate_idx < 0))
564 - return TX_DROP;
565 - } else
566 - info->control.retries[0].rate_idx = -1;
567 + len = min_t(int, tx->skb->len + FCS_LEN,
568 + tx->local->fragmentation_threshold);
569
570 - if (tx->sdata->vif.bss_conf.use_cts_prot &&
571 - (tx->flags & IEEE80211_TX_FRAGMENTED) && (rsel.nonerp_idx >= 0)) {
572 - tx->last_frag_rate_idx = tx->rate_idx;
573 - if (rsel.probe_idx >= 0)
574 - tx->flags &= ~IEEE80211_TX_PROBE_LAST_FRAG;
575 - else
576 - tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
577 - tx->rate_idx = rsel.nonerp_idx;
578 - info->tx_rate_idx = rsel.nonerp_idx;
579 - info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
580 - } else {
581 - tx->last_frag_rate_idx = tx->rate_idx;
582 - info->tx_rate_idx = tx->rate_idx;
583 + /* set up the tx rate control struct we give the RC algo */
584 + txrc.sband = sband;
585 + txrc.bss_conf = &tx->sdata->vif.bss_conf;
586 + txrc.skb = tx->skb;
587 + txrc.reported_rate.idx = -1;
588 + txrc.max_rate_idx = tx->sdata->max_ratectrl_rateidx;
589 +
590 + /* set up RTS protection if desired */
591 + if (tx->local->rts_threshold < IEEE80211_MAX_RTS_THRESHOLD &&
592 + len > tx->local->rts_threshold) {
593 + txrc.rts = rts = true;
594 }
595 - info->tx_rate_idx = tx->rate_idx;
596
597 - return TX_CONTINUE;
598 -}
599 + /* XXX: Is this really the right thing to check? */
600 + if (ieee80211_is_data(hdr->frame_control) &&
601 + tx->sdata->vif.bss_conf.use_short_preamble &&
602 + (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE)))
603 + txrc.short_preamble = short_preamble = true;
604
605 -static ieee80211_tx_result debug_noinline
606 -ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
607 -{
608 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
609 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
610 - struct ieee80211_supported_band *sband;
611
612 - sband = tx->local->hw.wiphy->bands[tx->channel->band];
613 + rate_control_get_rate(tx->sdata, tx->sta, &txrc);
614 +
615 + if (unlikely(info->control.rates[0].idx < 0))
616 + return TX_DROP;
617 +
618 + if (txrc.reported_rate.idx < 0)
619 + txrc.reported_rate = info->control.rates[0];
620
621 if (tx->sta)
622 - info->control.sta = &tx->sta->sta;
623 + tx->sta->last_tx_rate = txrc.reported_rate;
624
625 - if (!info->control.retry_limit) {
626 - if (!is_multicast_ether_addr(hdr->addr1)) {
627 - int len = min_t(int, tx->skb->len + FCS_LEN,
628 - tx->local->fragmentation_threshold);
629 - if (len > tx->local->rts_threshold
630 - && tx->local->rts_threshold <
631 - IEEE80211_MAX_RTS_THRESHOLD) {
632 - info->flags |= IEEE80211_TX_CTL_USE_RTS_CTS;
633 - info->flags |=
634 - IEEE80211_TX_CTL_LONG_RETRY_LIMIT;
635 - info->control.retry_limit =
636 - tx->local->hw.conf.long_frame_max_tx_count - 1;
637 - } else {
638 - info->control.retry_limit =
639 - tx->local->hw.conf.short_frame_max_tx_count - 1;
640 - }
641 - } else {
642 - info->control.retry_limit = 1;
643 - }
644 - }
645 + if (unlikely(!info->control.rates[0].count))
646 + info->control.rates[0].count = 1;
647
648 - if (tx->flags & IEEE80211_TX_FRAGMENTED) {
649 - /* Do not use multiple retry rates when sending fragmented
650 - * frames.
651 - * TODO: The last fragment could still use multiple retry
652 - * rates. */
653 - info->control.retries[0].rate_idx = -1;
654 - }
655 -
656 - /* Use CTS protection for unicast frames sent using extended rates if
657 - * there are associated non-ERP stations and RTS/CTS is not configured
658 - * for the frame. */
659 - if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) &&
660 - (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_ERP_G) &&
661 - (tx->flags & IEEE80211_TX_UNICAST) &&
662 - tx->sdata->vif.bss_conf.use_cts_prot &&
663 - !(info->flags & IEEE80211_TX_CTL_USE_RTS_CTS))
664 - info->flags |= IEEE80211_TX_CTL_USE_CTS_PROTECT;
665 -
666 - /* Transmit data frames using short preambles if the driver supports
667 - * short preambles at the selected rate and short preambles are
668 - * available on the network at the current point in time. */
669 - if (ieee80211_is_data(hdr->frame_control) &&
670 - (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) &&
671 - tx->sdata->vif.bss_conf.use_short_preamble &&
672 - (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) {
673 - info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE;
674 + if (is_multicast_ether_addr(hdr->addr1)) {
675 + /*
676 + * XXX: verify the rate is in the basic rateset
677 + */
678 + return TX_CONTINUE;
679 }
680
681 - if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
682 - (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) {
683 - struct ieee80211_rate *rate;
684 - s8 baserate = -1;
685 - int idx;
686 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
687 + /*
688 + * make sure there's no valid rate following
689 + * an invalid one, just in case drivers don't
690 + * take the API seriously to stop at -1.
691 + */
692 + if (inval) {
693 + info->control.rates[i].idx = -1;
694 + continue;
695 + }
696 + if (info->control.rates[i].idx < 0) {
697 + inval = true;
698 + continue;
699 + }
700
701 - /* Do not use multiple retry rates when using RTS/CTS */
702 - info->control.retries[0].rate_idx = -1;
703 + /*
704 + * For now assume MCS is already set up correctly, this
705 + * needs to be fixed.
706 + */
707 + if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) {
708 + WARN_ON(info->control.rates[i].idx > 76);
709 + continue;
710 + }
711
712 - /* Use min(data rate, max base rate) as CTS/RTS rate */
713 - rate = &sband->bitrates[tx->rate_idx];
714 + /* set up RTS protection if desired */
715 + if (rts) {
716 + info->control.rates[i].flags |=
717 + IEEE80211_TX_RC_USE_RTS_CTS;
718 + rts = true;
719 + }
720
721 - for (idx = 0; idx < sband->n_bitrates; idx++) {
722 - if (sband->bitrates[idx].bitrate > rate->bitrate)
723 - continue;
724 - if (tx->sdata->vif.bss_conf.basic_rates & BIT(idx) &&
725 - (baserate < 0 ||
726 - (sband->bitrates[baserate].bitrate
727 - < sband->bitrates[idx].bitrate)))
728 - baserate = idx;
729 + /* RC is busted */
730 + if (WARN_ON(info->control.rates[i].idx >=
731 + sband->n_bitrates)) {
732 + info->control.rates[i].idx = -1;
733 + continue;
734 }
735
736 - if (baserate >= 0)
737 - info->control.rts_cts_rate_idx = baserate;
738 - else
739 - info->control.rts_cts_rate_idx = 0;
740 + rate = &sband->bitrates[info->control.rates[i].idx];
741 +
742 + /* set up short preamble */
743 + if (short_preamble &&
744 + rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
745 + info->control.rates[i].flags |=
746 + IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
747 +
748 + /* set up G protection */
749 + if (!rts && tx->sdata->vif.bss_conf.use_cts_prot &&
750 + rate->flags & IEEE80211_RATE_ERP_G)
751 + info->control.rates[i].flags |=
752 + IEEE80211_TX_RC_USE_CTS_PROTECT;
753 }
754
755 + return TX_CONTINUE;
756 +}
757 +
758 +static ieee80211_tx_result debug_noinline
759 +ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
760 +{
761 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
762 +
763 if (tx->sta)
764 info->control.sta = &tx->sta->sta;
765
766 @@ -680,6 +670,7 @@ ieee80211_tx_h_fragment(struct ieee80211
767 left = payload_len - per_fragm;
768 for (i = 0; i < num_fragm - 1; i++) {
769 struct ieee80211_hdr *fhdr;
770 + struct ieee80211_tx_info *info;
771 size_t copylen;
772
773 if (left <= 0)
774 @@ -694,20 +685,44 @@ ieee80211_tx_h_fragment(struct ieee80211
775 IEEE80211_ENCRYPT_TAILROOM);
776 if (!frag)
777 goto fail;
778 +
779 /* Make sure that all fragments use the same priority so
780 * that they end up using the same TX queue */
781 frag->priority = first->priority;
782 +
783 skb_reserve(frag, tx->local->tx_headroom +
784 IEEE80211_ENCRYPT_HEADROOM);
785 +
786 + /* copy TX information */
787 + info = IEEE80211_SKB_CB(frag);
788 + memcpy(info, first->cb, sizeof(frag->cb));
789 +
790 + /* copy/fill in 802.11 header */
791 fhdr = (struct ieee80211_hdr *) skb_put(frag, hdrlen);
792 memcpy(fhdr, first->data, hdrlen);
793 - if (i == num_fragm - 2)
794 - fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS);
795 fhdr->seq_ctrl = cpu_to_le16(seq | ((i + 1) & IEEE80211_SCTL_FRAG));
796 +
797 + if (i == num_fragm - 2) {
798 + /* clear MOREFRAGS bit for the last fragment */
799 + fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS);
800 + } else {
801 + /*
802 + * No multi-rate retries for fragmented frames, that
803 + * would completely throw off the NAV at other STAs.
804 + */
805 + info->control.rates[1].idx = -1;
806 + info->control.rates[2].idx = -1;
807 + info->control.rates[3].idx = -1;
808 + BUILD_BUG_ON(IEEE80211_TX_MAX_RATES != 4);
809 + info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
810 + }
811 +
812 + /* copy data */
813 copylen = left > per_fragm ? per_fragm : left;
814 memcpy(skb_put(frag, copylen), pos, copylen);
815 - memcpy(frag->cb, first->cb, sizeof(frag->cb));
816 +
817 skb_copy_queue_mapping(frag, first);
818 +
819 frag->do_not_encrypt = first->do_not_encrypt;
820
821 pos += copylen;
822 @@ -767,12 +782,10 @@ ieee80211_tx_h_calculate_duration(struct
823 tx->extra_frag[0]->len);
824
825 for (i = 0; i < tx->num_extra_frag; i++) {
826 - if (i + 1 < tx->num_extra_frag) {
827 + if (i + 1 < tx->num_extra_frag)
828 next_len = tx->extra_frag[i + 1]->len;
829 - } else {
830 + else
831 next_len = 0;
832 - tx->rate_idx = tx->last_frag_rate_idx;
833 - }
834
835 hdr = (struct ieee80211_hdr *)tx->extra_frag[i]->data;
836 hdr->duration_id = ieee80211_duration(tx, 0, next_len);
837 @@ -825,7 +838,6 @@ __ieee80211_parse_tx_radiotap(struct iee
838 (struct ieee80211_radiotap_header *) skb->data;
839 struct ieee80211_supported_band *sband;
840 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len);
841 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
842
843 sband = tx->local->hw.wiphy->bands[tx->channel->band];
844
845 @@ -839,8 +851,6 @@ __ieee80211_parse_tx_radiotap(struct iee
846 */
847
848 while (!ret) {
849 - int i, target_rate;
850 -
851 ret = ieee80211_radiotap_iterator_next(&iterator);
852
853 if (ret)
854 @@ -854,38 +864,6 @@ __ieee80211_parse_tx_radiotap(struct iee
855 * get_unaligned((type *)iterator.this_arg) to dereference
856 * iterator.this_arg for type "type" safely on all arches.
857 */
858 - case IEEE80211_RADIOTAP_RATE:
859 - /*
860 - * radiotap rate u8 is in 500kbps units eg, 0x02=1Mbps
861 - * ieee80211 rate int is in 100kbps units eg, 0x0a=1Mbps
862 - */
863 - target_rate = (*iterator.this_arg) * 5;
864 - for (i = 0; i < sband->n_bitrates; i++) {
865 - struct ieee80211_rate *r;
866 -
867 - r = &sband->bitrates[i];
868 -
869 - if (r->bitrate == target_rate) {
870 - tx->rate_idx = i;
871 - break;
872 - }
873 - }
874 - break;
875 -
876 - case IEEE80211_RADIOTAP_ANTENNA:
877 - /*
878 - * radiotap uses 0 for 1st ant, mac80211 is 1 for
879 - * 1st ant
880 - */
881 - info->antenna_sel_tx = (*iterator.this_arg) + 1;
882 - break;
883 -
884 -#if 0
885 - case IEEE80211_RADIOTAP_DBM_TX_POWER:
886 - control->power_level = *iterator.this_arg;
887 - break;
888 -#endif
889 -
890 case IEEE80211_RADIOTAP_FLAGS:
891 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) {
892 /*
893 @@ -951,8 +929,6 @@ __ieee80211_tx_prepare(struct ieee80211_
894 tx->local = local;
895 tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev);
896 tx->channel = local->hw.conf.channel;
897 - tx->rate_idx = -1;
898 - tx->last_frag_rate_idx = -1;
899 /*
900 * Set this flag (used below to indicate "automatic fragmentation"),
901 * it will be cleared/left by radiotap as desired.
902 @@ -1053,23 +1029,11 @@ static int __ieee80211_tx(struct ieee802
903 if (!tx->extra_frag[i])
904 continue;
905 info = IEEE80211_SKB_CB(tx->extra_frag[i]);
906 - info->flags &= ~(IEEE80211_TX_CTL_USE_RTS_CTS |
907 - IEEE80211_TX_CTL_USE_CTS_PROTECT |
908 - IEEE80211_TX_CTL_CLEAR_PS_FILT |
909 + info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT |
910 IEEE80211_TX_CTL_FIRST_FRAGMENT);
911 if (netif_subqueue_stopped(local->mdev,
912 tx->extra_frag[i]))
913 return IEEE80211_TX_FRAG_AGAIN;
914 - if (i == tx->num_extra_frag) {
915 - info->tx_rate_idx = tx->last_frag_rate_idx;
916 -
917 - if (tx->flags & IEEE80211_TX_PROBE_LAST_FRAG)
918 - info->flags |=
919 - IEEE80211_TX_CTL_RATE_CTRL_PROBE;
920 - else
921 - info->flags &=
922 - ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
923 - }
924
925 ret = local->ops->tx(local_to_hw(local),
926 tx->extra_frag[i]);
927 @@ -1206,9 +1170,6 @@ retry:
928 store->skb = skb;
929 store->extra_frag = tx.extra_frag;
930 store->num_extra_frag = tx.num_extra_frag;
931 - store->last_frag_rate_idx = tx.last_frag_rate_idx;
932 - store->last_frag_rate_ctrl_probe =
933 - !!(tx.flags & IEEE80211_TX_PROBE_LAST_FRAG);
934 }
935 out:
936 rcu_read_unlock();
937 @@ -1767,10 +1728,7 @@ void ieee80211_tx_pending(unsigned long
938 store = &local->pending_packet[i];
939 tx.extra_frag = store->extra_frag;
940 tx.num_extra_frag = store->num_extra_frag;
941 - tx.last_frag_rate_idx = store->last_frag_rate_idx;
942 tx.flags = 0;
943 - if (store->last_frag_rate_ctrl_probe)
944 - tx.flags |= IEEE80211_TX_PROBE_LAST_FRAG;
945 ret = __ieee80211_tx(local, store->skb, &tx);
946 if (ret) {
947 if (ret == IEEE80211_TX_FRAG_AGAIN)
948 @@ -1858,7 +1816,6 @@ struct sk_buff *ieee80211_beacon_get(str
949 struct ieee80211_sub_if_data *sdata = NULL;
950 struct ieee80211_if_ap *ap = NULL;
951 struct ieee80211_if_sta *ifsta = NULL;
952 - struct rate_selection rsel;
953 struct beacon_data *beacon;
954 struct ieee80211_supported_band *sband;
955 enum ieee80211_band band = local->hw.conf.channel->band;
956 @@ -1962,32 +1919,22 @@ struct sk_buff *ieee80211_beacon_get(str
957 skb->do_not_encrypt = 1;
958
959 info->band = band;
960 - rate_control_get_rate(sdata, sband, NULL, skb, &rsel);
961 -
962 - if (unlikely(rsel.rate_idx < 0)) {
963 - if (net_ratelimit()) {
964 - printk(KERN_DEBUG "%s: ieee80211_beacon_get: "
965 - "no rate found\n",
966 - wiphy_name(local->hw.wiphy));
967 - }
968 - dev_kfree_skb_any(skb);
969 - skb = NULL;
970 - goto out;
971 - }
972 + /*
973 + * XXX: For now, always use the lowest rate
974 + */
975 + info->control.rates[0].idx = 0;
976 + info->control.rates[0].count = 1;
977 + info->control.rates[1].idx = -1;
978 + info->control.rates[2].idx = -1;
979 + info->control.rates[3].idx = -1;
980 + BUILD_BUG_ON(IEEE80211_TX_MAX_RATES != 4);
981
982 info->control.vif = vif;
983 - info->tx_rate_idx = rsel.rate_idx;
984
985 info->flags |= IEEE80211_TX_CTL_NO_ACK;
986 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
987 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
988 - if (sdata->vif.bss_conf.use_short_preamble &&
989 - sband->bitrates[rsel.rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE)
990 - info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE;
991 -
992 - info->control.retry_limit = 1;
993 -
994 -out:
995 + out:
996 rcu_read_unlock();
997 return skb;
998 }
999 --- a/net/mac80211/ieee80211_i.h
1000 +++ b/net/mac80211/ieee80211_i.h
1001 @@ -142,7 +142,6 @@ typedef unsigned __bitwise__ ieee80211_t
1002 #define IEEE80211_TX_FRAGMENTED BIT(0)
1003 #define IEEE80211_TX_UNICAST BIT(1)
1004 #define IEEE80211_TX_PS_BUFFERED BIT(2)
1005 -#define IEEE80211_TX_PROBE_LAST_FRAG BIT(3)
1006
1007 struct ieee80211_tx_data {
1008 struct sk_buff *skb;
1009 @@ -153,11 +152,6 @@ struct ieee80211_tx_data {
1010 struct ieee80211_key *key;
1011
1012 struct ieee80211_channel *channel;
1013 - s8 rate_idx;
1014 - /* use this rate (if set) for last fragment; rate can
1015 - * be set to lower rate for the first fragments, e.g.,
1016 - * when using CTS protection with IEEE 802.11g. */
1017 - s8 last_frag_rate_idx;
1018
1019 /* Extra fragments (in addition to the first fragment
1020 * in skb) */
1021 @@ -203,9 +197,7 @@ struct ieee80211_rx_data {
1022 struct ieee80211_tx_stored_packet {
1023 struct sk_buff *skb;
1024 struct sk_buff **extra_frag;
1025 - s8 last_frag_rate_idx;
1026 int num_extra_frag;
1027 - bool last_frag_rate_ctrl_probe;
1028 };
1029
1030 struct beacon_data {
1031 --- a/net/mac80211/rate.c
1032 +++ b/net/mac80211/rate.c
1033 @@ -199,48 +199,44 @@ static void rate_control_release(struct
1034 }
1035
1036 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
1037 - struct ieee80211_supported_band *sband,
1038 - struct sta_info *sta, struct sk_buff *skb,
1039 - struct rate_selection *sel)
1040 + struct sta_info *sta,
1041 + struct ieee80211_tx_rate_control *txrc)
1042 {
1043 struct rate_control_ref *ref = sdata->local->rate_ctrl;
1044 void *priv_sta = NULL;
1045 struct ieee80211_sta *ista = NULL;
1046 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
1047 int i;
1048
1049 - sel->rate_idx = -1;
1050 - sel->nonerp_idx = -1;
1051 - sel->probe_idx = -1;
1052 - sel->max_rate_idx = sdata->max_ratectrl_rateidx;
1053 -
1054 if (sta) {
1055 ista = &sta->sta;
1056 priv_sta = sta->rate_ctrl_priv;
1057 }
1058
1059 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
1060 + info->control.rates[i].idx = -1;
1061 + info->control.rates[i].flags = 0;
1062 + info->control.rates[i].count = 1;
1063 + }
1064 +
1065 if (sta && sdata->force_unicast_rateidx > -1)
1066 - sel->rate_idx = sdata->force_unicast_rateidx;
1067 + info->control.rates[0].idx = sdata->force_unicast_rateidx;
1068 else
1069 - ref->ops->get_rate(ref->priv, sband, ista, priv_sta, skb, sel);
1070 + ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
1071
1072 - if (sdata->max_ratectrl_rateidx > -1 &&
1073 - sel->rate_idx > sdata->max_ratectrl_rateidx)
1074 - sel->rate_idx = sdata->max_ratectrl_rateidx;
1075 -
1076 - BUG_ON(sel->rate_idx < 0);
1077 -
1078 - /* Select a non-ERP backup rate. */
1079 - if (sel->nonerp_idx < 0) {
1080 - for (i = 0; i < sband->n_bitrates; i++) {
1081 - struct ieee80211_rate *rate = &sband->bitrates[i];
1082 - if (sband->bitrates[sel->rate_idx].bitrate < rate->bitrate)
1083 - break;
1084 -
1085 - if (rate_supported(ista, sband->band, i) &&
1086 - !(rate->flags & IEEE80211_RATE_ERP_G))
1087 - sel->nonerp_idx = i;
1088 - }
1089 + /*
1090 + * try to enforce the maximum rate the user wanted
1091 + */
1092 + if (sdata->max_ratectrl_rateidx > -1)
1093 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
1094 + if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS)
1095 + continue;
1096 + info->control.rates[i].idx =
1097 + min_t(s8, info->control.rates[i].idx,
1098 + sdata->max_ratectrl_rateidx);
1099 }
1100 +
1101 + BUG_ON(info->control.rates[0].idx < 0);
1102 }
1103
1104 struct rate_control_ref *rate_control_get(struct rate_control_ref *ref)
1105 --- a/net/mac80211/rate.h
1106 +++ b/net/mac80211/rate.h
1107 @@ -31,9 +31,8 @@ struct rate_control_ref {
1108 struct rate_control_ref *rate_control_alloc(const char *name,
1109 struct ieee80211_local *local);
1110 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
1111 - struct ieee80211_supported_band *sband,
1112 - struct sta_info *sta, struct sk_buff *skb,
1113 - struct rate_selection *sel);
1114 + struct sta_info *sta,
1115 + struct ieee80211_tx_rate_control *txrc);
1116 struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
1117 void rate_control_put(struct rate_control_ref *ref);
1118
1119 --- a/net/mac80211/sta_info.h
1120 +++ b/net/mac80211/sta_info.h
1121 @@ -196,7 +196,7 @@ struct sta_ampdu_mlme {
1122 * @tx_packets: number of RX/TX MSDUs
1123 * @tx_bytes: TBD
1124 * @tx_fragments: number of transmitted MPDUs
1125 - * @last_txrate_idx: Index of the last used transmit rate
1126 + * @last_txrate: description of the last used transmit rate
1127 * @tid_seq: TBD
1128 * @ampdu_mlme: TBD
1129 * @timer_to_tid: identity mapping to ID timers
1130 @@ -267,7 +267,7 @@ struct sta_info {
1131 unsigned long tx_packets;
1132 unsigned long tx_bytes;
1133 unsigned long tx_fragments;
1134 - unsigned int last_txrate_idx;
1135 + struct ieee80211_tx_rate last_tx_rate;
1136 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
1137
1138 /*
1139 --- a/net/mac80211/wext.c
1140 +++ b/net/mac80211/wext.c
1141 @@ -636,8 +636,8 @@ static int ieee80211_ioctl_giwrate(struc
1142
1143 sta = sta_info_get(local, sdata->u.sta.bssid);
1144
1145 - if (sta && sta->last_txrate_idx < sband->n_bitrates)
1146 - rate->value = sband->bitrates[sta->last_txrate_idx].bitrate;
1147 + if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS))
1148 + rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate;
1149 else
1150 rate->value = 0;
1151
1152 --- a/net/mac80211/mesh_hwmp.c
1153 +++ b/net/mac80211/mesh_hwmp.c
1154 @@ -218,12 +218,16 @@ static u32 airtime_link_metric_get(struc
1155
1156 if (sta->fail_avg >= 100)
1157 return MAX_METRIC;
1158 +
1159 + if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
1160 + return MAX_METRIC;
1161 +
1162 err = (sta->fail_avg << ARITH_SHIFT) / 100;
1163
1164 /* bitrate is in units of 100 Kbps, while we need rate in units of
1165 * 1Mbps. This will be corrected on tx_time computation.
1166 */
1167 - rate = sband->bitrates[sta->last_txrate_idx].bitrate;
1168 + rate = sband->bitrates[sta->last_tx_rate.idx].bitrate;
1169 tx_time = (device_constant + 10 * test_frame_len / rate);
1170 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err));
1171 result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ;
1172 --- a/net/mac80211/rc80211_pid_algo.c
1173 +++ b/net/mac80211/rc80211_pid_algo.c
1174 @@ -241,7 +241,7 @@ static void rate_control_pid_tx_status(v
1175
1176 /* Ignore all frames that were sent with a different rate than the rate
1177 * we currently advise mac80211 to use. */
1178 - if (info->tx_rate_idx != spinfo->txrate_idx)
1179 + if (info->status.rates[0].idx != spinfo->txrate_idx)
1180 return;
1181
1182 spinfo->tx_num_xmit++;
1183 @@ -253,10 +253,10 @@ static void rate_control_pid_tx_status(v
1184 /* We count frames that totally failed to be transmitted as two bad
1185 * frames, those that made it out but had some retries as one good and
1186 * one bad frame. */
1187 - if (info->status.excessive_retries) {
1188 + if (!(info->flags & IEEE80211_TX_STAT_ACK)) {
1189 spinfo->tx_num_failed += 2;
1190 spinfo->tx_num_xmit++;
1191 - } else if (info->status.retry_count) {
1192 + } else if (info->status.rates[0].count) {
1193 spinfo->tx_num_failed++;
1194 spinfo->tx_num_xmit++;
1195 }
1196 @@ -270,23 +270,31 @@ static void rate_control_pid_tx_status(v
1197 }
1198
1199 static void
1200 -rate_control_pid_get_rate(void *priv, struct ieee80211_supported_band *sband,
1201 - struct ieee80211_sta *sta, void *priv_sta,
1202 - struct sk_buff *skb,
1203 - struct rate_selection *sel)
1204 +rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta,
1205 + void *priv_sta,
1206 + struct ieee80211_tx_rate_control *txrc)
1207 {
1208 + struct sk_buff *skb = txrc->skb;
1209 + struct ieee80211_supported_band *sband = txrc->sband;
1210 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1211 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1212 struct rc_pid_sta_info *spinfo = priv_sta;
1213 int rateidx;
1214 u16 fc;
1215
1216 + /* XXX: Should use the user-configured values */
1217 + if (txrc->rts)
1218 + info->control.rates[0].count = 4; /* long retry count */
1219 + else
1220 + info->control.rates[0].count = 7; /* short retry count */
1221 +
1222 /* Send management frames and broadcast/multicast data using lowest
1223 * rate. */
1224 fc = le16_to_cpu(hdr->frame_control);
1225 if (!sta || !spinfo ||
1226 (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
1227 is_multicast_ether_addr(hdr->addr1)) {
1228 - sel->rate_idx = rate_lowest_index(sband, sta);
1229 + info->control.rates[0].idx = rate_lowest_index(sband, sta);
1230 return;
1231 }
1232
1233 @@ -295,7 +303,7 @@ rate_control_pid_get_rate(void *priv, st
1234 if (rateidx >= sband->n_bitrates)
1235 rateidx = sband->n_bitrates - 1;
1236
1237 - sel->rate_idx = rateidx;
1238 + info->control.rates[0].idx = rateidx;
1239
1240 #ifdef CONFIG_MAC80211_DEBUGFS
1241 rate_control_pid_event_tx_rate(&spinfo->events,
1242 --- a/net/mac80211/rc80211_minstrel.c
1243 +++ b/net/mac80211/rc80211_minstrel.c
1244 @@ -169,30 +169,20 @@ minstrel_tx_status(void *priv, struct ie
1245 {
1246 struct minstrel_sta_info *mi = priv_sta;
1247 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1248 - struct ieee80211_tx_altrate *ar = info->status.retries;
1249 - struct minstrel_priv *mp = priv;
1250 - int i, ndx, tries;
1251 - int success = 0;
1252 + struct ieee80211_tx_rate *ar = info->status.rates;
1253 + int i, ndx;
1254 + int success;
1255
1256 - if (!info->status.excessive_retries)
1257 - success = 1;
1258 + success = !!(info->flags & IEEE80211_TX_STAT_ACK);
1259
1260 - if (!mp->has_mrr || (ar[0].rate_idx < 0)) {
1261 - ndx = rix_to_ndx(mi, info->tx_rate_idx);
1262 - tries = info->status.retry_count + 1;
1263 - mi->r[ndx].success += success;
1264 - mi->r[ndx].attempts += tries;
1265 - return;
1266 - }
1267 -
1268 - for (i = 0; i < 4; i++) {
1269 - if (ar[i].rate_idx < 0)
1270 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
1271 + if (ar[i].idx < 0)
1272 break;
1273
1274 - ndx = rix_to_ndx(mi, ar[i].rate_idx);
1275 - mi->r[ndx].attempts += ar[i].limit + 1;
1276 + ndx = rix_to_ndx(mi, ar[i].idx);
1277 + mi->r[ndx].attempts += ar[i].count;
1278
1279 - if ((i != 3) && (ar[i + 1].rate_idx < 0))
1280 + if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0))
1281 mi->r[ndx].success += success;
1282 }
1283
1284 @@ -210,9 +200,9 @@ minstrel_get_retry_count(struct minstrel
1285 {
1286 unsigned int retry = mr->adjusted_retry_count;
1287
1288 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
1289 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1290 retry = max(2U, min(mr->retry_count_rtscts, retry));
1291 - else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
1292 + else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1293 retry = max(2U, min(mr->retry_count_cts, retry));
1294 return retry;
1295 }
1296 @@ -234,14 +224,15 @@ minstrel_get_next_sample(struct minstrel
1297 }
1298
1299 void
1300 -minstrel_get_rate(void *priv, struct ieee80211_supported_band *sband,
1301 - struct ieee80211_sta *sta, void *priv_sta,
1302 - struct sk_buff *skb, struct rate_selection *sel)
1303 +minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
1304 + void *priv_sta, struct ieee80211_tx_rate_control *txrc)
1305 {
1306 + struct sk_buff *skb = txrc->skb;
1307 + struct ieee80211_supported_band *sband = txrc->sband;
1308 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1309 struct minstrel_sta_info *mi = priv_sta;
1310 struct minstrel_priv *mp = priv;
1311 - struct ieee80211_tx_altrate *ar = info->control.retries;
1312 + struct ieee80211_tx_rate *ar = info->control.rates;
1313 unsigned int ndx, sample_ndx = 0;
1314 bool mrr;
1315 bool sample_slower = false;
1316 @@ -251,16 +242,12 @@ minstrel_get_rate(void *priv, struct iee
1317 int sample_rate;
1318
1319 if (!sta || !mi || use_low_rate(skb)) {
1320 - sel->rate_idx = rate_lowest_index(sband, sta);
1321 + ar[0].idx = rate_lowest_index(sband, sta);
1322 + ar[0].count = mp->max_retry;
1323 return;
1324 }
1325
1326 - mrr = mp->has_mrr;
1327 -
1328 - /* mac80211 does not allow mrr for RTS/CTS */
1329 - if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
1330 - (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT))
1331 - mrr = false;
1332 + mrr = mp->has_mrr && !txrc->rts && !txrc->bss_conf->use_cts_prot;
1333
1334 if (time_after(jiffies, mi->stats_update + (mp->update_interval *
1335 HZ) / 1000))
1336 @@ -315,13 +302,12 @@ minstrel_get_rate(void *priv, struct iee
1337 mi->sample_deferred++;
1338 }
1339 }
1340 - sel->rate_idx = mi->r[ndx].rix;
1341 - info->control.retry_limit = minstrel_get_retry_count(&mi->r[ndx], info);
1342 + ar[0].idx = mi->r[ndx].rix;
1343 + ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
1344
1345 if (!mrr) {
1346 - ar[0].rate_idx = mi->lowest_rix;
1347 - ar[0].limit = mp->max_retry;
1348 - ar[1].rate_idx = -1;
1349 + ar[1].idx = mi->lowest_rix;
1350 + ar[1].count = mp->max_retry;
1351 return;
1352 }
1353
1354 @@ -336,9 +322,9 @@ minstrel_get_rate(void *priv, struct iee
1355 }
1356 mrr_ndx[1] = mi->max_prob_rate;
1357 mrr_ndx[2] = 0;
1358 - for (i = 0; i < 3; i++) {
1359 - ar[i].rate_idx = mi->r[mrr_ndx[i]].rix;
1360 - ar[i].limit = mi->r[mrr_ndx[i]].adjusted_retry_count;
1361 + for (i = 1; i < 4; i++) {
1362 + ar[i].idx = mi->r[mrr_ndx[i - 1]].rix;
1363 + ar[i].count = mi->r[mrr_ndx[i - 1]].adjusted_retry_count;
1364 }
1365 }
1366
1367 @@ -532,13 +518,13 @@ minstrel_alloc(struct ieee80211_hw *hw,
1368 /* maximum time that the hw is allowed to stay in one MRR segment */
1369 mp->segment_size = 6000;
1370
1371 - if (hw->max_altrate_tries > 0)
1372 - mp->max_retry = hw->max_altrate_tries;
1373 + if (hw->max_rate_tries > 0)
1374 + mp->max_retry = hw->max_rate_tries;
1375 else
1376 /* safe default, does not necessarily have to match hw properties */
1377 mp->max_retry = 7;
1378
1379 - if (hw->max_altrates >= 3)
1380 + if (hw->max_rates >= 4)
1381 mp->has_mrr = true;
1382
1383 mp->hw = hw;
1384 --- a/net/mac80211/rc80211_pid_debugfs.c
1385 +++ b/net/mac80211/rc80211_pid_debugfs.c
1386 @@ -43,6 +43,7 @@ void rate_control_pid_event_tx_status(st
1387 {
1388 union rc_pid_event_data evd;
1389
1390 + evd.flags = stat->flags;
1391 memcpy(&evd.tx_status, stat, sizeof(struct ieee80211_tx_info));
1392 rate_control_pid_event(buf, RC_PID_EVENT_TYPE_TX_STATUS, &evd);
1393 }
1394 @@ -167,8 +168,8 @@ static ssize_t rate_control_pid_events_r
1395 switch (ev->type) {
1396 case RC_PID_EVENT_TYPE_TX_STATUS:
1397 p += snprintf(pb + p, length - p, "tx_status %u %u",
1398 - ev->data.tx_status.status.excessive_retries,
1399 - ev->data.tx_status.status.retry_count);
1400 + !(ev->data.flags & IEEE80211_TX_STAT_ACK),
1401 + ev->data.tx_status.status.rates[0].idx);
1402 break;
1403 case RC_PID_EVENT_TYPE_RATE_CHANGE:
1404 p += snprintf(pb + p, length - p, "rate_change %d %d",
1405 --- a/net/mac80211/rc80211_pid.h
1406 +++ b/net/mac80211/rc80211_pid.h
1407 @@ -61,6 +61,7 @@ enum rc_pid_event_type {
1408 union rc_pid_event_data {
1409 /* RC_PID_EVENT_TX_STATUS */
1410 struct {
1411 + u32 flags;
1412 struct ieee80211_tx_info tx_status;
1413 };
1414 /* RC_PID_EVENT_TYPE_RATE_CHANGE */
1415 --- a/drivers/net/wireless/zd1211rw/zd_mac.c
1416 +++ b/drivers/net/wireless/zd1211rw/zd_mac.c
1417 @@ -296,15 +296,14 @@ static void zd_op_stop(struct ieee80211_
1418 * If no status information has been requested, the skb is freed.
1419 */
1420 static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
1421 - u32 flags, int ackssi, bool success)
1422 + int ackssi, bool success)
1423 {
1424 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1425
1426 - memset(&info->status, 0, sizeof(info->status));
1427 + ieee80211_tx_info_clear_status(info);
1428
1429 - if (!success)
1430 - info->status.excessive_retries = 1;
1431 - info->flags |= flags;
1432 + if (success)
1433 + info->flags |= IEEE80211_TX_STAT_ACK;
1434 info->status.ack_signal = ackssi;
1435 ieee80211_tx_status_irqsafe(hw, skb);
1436 }
1437 @@ -326,7 +325,7 @@ void zd_mac_tx_failed(struct ieee80211_h
1438 if (skb == NULL)
1439 return;
1440
1441 - tx_status(hw, skb, 0, 0, 0);
1442 + tx_status(hw, skb, 0, 0);
1443 }
1444
1445 /**
1446 @@ -347,7 +346,7 @@ void zd_mac_tx_to_dev(struct sk_buff *sk
1447 skb_pull(skb, sizeof(struct zd_ctrlset));
1448 if (unlikely(error ||
1449 (info->flags & IEEE80211_TX_CTL_NO_ACK))) {
1450 - tx_status(hw, skb, 0, 0, !error);
1451 + tx_status(hw, skb, 0, !error);
1452 } else {
1453 struct sk_buff_head *q =
1454 &zd_hw_mac(hw)->ack_wait_queue;
1455 @@ -406,7 +405,8 @@ static int zd_calc_tx_length_us(u8 *serv
1456 }
1457
1458 static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
1459 - struct ieee80211_hdr *header, u32 flags)
1460 + struct ieee80211_hdr *header,
1461 + struct ieee80211_tx_info *info)
1462 {
1463 /*
1464 * CONTROL TODO:
1465 @@ -417,7 +417,7 @@ static void cs_set_control(struct zd_mac
1466 cs->control = 0;
1467
1468 /* First fragment */
1469 - if (flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
1470 + if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
1471 cs->control |= ZD_CS_NEED_RANDOM_BACKOFF;
1472
1473 /* Multicast */
1474 @@ -428,10 +428,10 @@ static void cs_set_control(struct zd_mac
1475 if (ieee80211_is_pspoll(header->frame_control))
1476 cs->control |= ZD_CS_PS_POLL_FRAME;
1477
1478 - if (flags & IEEE80211_TX_CTL_USE_RTS_CTS)
1479 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1480 cs->control |= ZD_CS_RTS;
1481
1482 - if (flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
1483 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1484 cs->control |= ZD_CS_SELF_CTS;
1485
1486 /* FIXME: Management frame? */
1487 @@ -517,12 +517,12 @@ static int fill_ctrlset(struct zd_mac *m
1488 txrate = ieee80211_get_tx_rate(mac->hw, info);
1489
1490 cs->modulation = txrate->hw_value;
1491 - if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE)
1492 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
1493 cs->modulation = txrate->hw_value_short;
1494
1495 cs->tx_length = cpu_to_le16(frag_len);
1496
1497 - cs_set_control(mac, cs, hdr, info->flags);
1498 + cs_set_control(mac, cs, hdr, info);
1499
1500 packet_length = frag_len + sizeof(struct zd_ctrlset) + 10;
1501 ZD_ASSERT(packet_length <= 0xffff);
1502 @@ -618,7 +618,7 @@ static int filter_ack(struct ieee80211_h
1503 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1)))
1504 {
1505 __skb_unlink(skb, q);
1506 - tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1);
1507 + tx_status(hw, skb, stats->signal, 1);
1508 goto out;
1509 }
1510 }
1511 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
1512 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
1513 @@ -499,6 +499,7 @@ void rt2x00lib_txdone(struct queue_entry
1514 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1515 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
1516 enum data_queue_qid qid = skb_get_queue_mapping(entry->skb);
1517 + bool rts;
1518
1519 /*
1520 * Unmap the skb.
1521 @@ -528,14 +529,14 @@ void rt2x00lib_txdone(struct queue_entry
1522 rt2x00dev->link.qual.tx_failed +=
1523 test_bit(TXDONE_FAILURE, &txdesc->flags);
1524
1525 + rts = !!(tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS);
1526 +
1527 /*
1528 * Initialize TX status
1529 */
1530 - memset(&tx_info->status, 0, sizeof(tx_info->status));
1531 + ieee80211_tx_info_clear_status(tx_info);
1532 tx_info->status.ack_signal = 0;
1533 - tx_info->status.excessive_retries =
1534 - test_bit(TXDONE_EXCESSIVE_RETRY, &txdesc->flags);
1535 - tx_info->status.retry_count = txdesc->retry;
1536 + tx_info->status.rates[0].count = txdesc->retry + 1;
1537
1538 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
1539 if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
1540 @@ -544,7 +545,7 @@ void rt2x00lib_txdone(struct queue_entry
1541 rt2x00dev->low_level_stats.dot11ACKFailureCount++;
1542 }
1543
1544 - if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
1545 + if (rts) {
1546 if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
1547 rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
1548 else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
1549 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
1550 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
1551 @@ -39,7 +39,7 @@ static int rt2x00mac_tx_rts_cts(struct r
1552 unsigned int data_length;
1553 int retval = 0;
1554
1555 - if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
1556 + if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1557 data_length = sizeof(struct ieee80211_cts);
1558 else
1559 data_length = sizeof(struct ieee80211_rts);
1560 @@ -64,11 +64,11 @@ static int rt2x00mac_tx_rts_cts(struct r
1561 */
1562 memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb));
1563 rts_info = IEEE80211_SKB_CB(skb);
1564 - rts_info->flags &= ~IEEE80211_TX_CTL_USE_RTS_CTS;
1565 - rts_info->flags &= ~IEEE80211_TX_CTL_USE_CTS_PROTECT;
1566 + rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS;
1567 + rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_CTS_PROTECT;
1568 rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS;
1569
1570 - if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
1571 + if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1572 rts_info->flags |= IEEE80211_TX_CTL_NO_ACK;
1573 else
1574 rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK;
1575 @@ -84,7 +84,7 @@ static int rt2x00mac_tx_rts_cts(struct r
1576 data_length += rt2x00crypto_tx_overhead(tx_info);
1577 #endif /* CONFIG_RT2X00_LIB_CRYPTO */
1578
1579 - if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
1580 + if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1581 ieee80211_ctstoself_get(rt2x00dev->hw, tx_info->control.vif,
1582 frag_skb->data, data_length, tx_info,
1583 (struct ieee80211_cts *)(skb->data));
1584 @@ -146,8 +146,8 @@ int rt2x00mac_tx(struct ieee80211_hw *hw
1585 * inside the hardware.
1586 */
1587 frame_control = le16_to_cpu(ieee80211hdr->frame_control);
1588 - if ((tx_info->flags & (IEEE80211_TX_CTL_USE_RTS_CTS |
1589 - IEEE80211_TX_CTL_USE_CTS_PROTECT)) &&
1590 + if ((tx_info->control.rates[0].flags & (IEEE80211_TX_RC_USE_RTS_CTS |
1591 + IEEE80211_TX_RC_USE_CTS_PROTECT)) &&
1592 !rt2x00dev->ops->hw->set_rts_threshold) {
1593 if (rt2x00queue_available(queue) <= 1)
1594 goto exit_fail;
1595 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
1596 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
1597 @@ -230,8 +230,15 @@ static void rt2x00queue_create_tx_descri
1598 /*
1599 * Determine retry information.
1600 */
1601 - txdesc->retry_limit = tx_info->control.retry_limit;
1602 - if (tx_info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT)
1603 + txdesc->retry_limit = tx_info->control.rates[0].count - 1;
1604 + /*
1605 + * XXX: If at this point we knew whether the HW is going to use
1606 + * the RETRY_MODE bit or the retry_limit (currently all
1607 + * use the RETRY_MODE bit) we could do something like b43
1608 + * does, set the RETRY_MODE bit when the RC algorithm is
1609 + * requesting more than the long retry limit.
1610 + */
1611 + if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1612 __set_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags);
1613
1614 /*
1615 --- a/drivers/net/wireless/adm8211.c
1616 +++ b/drivers/net/wireless/adm8211.c
1617 @@ -341,15 +341,14 @@ static void adm8211_interrupt_tci(struct
1618 pci_unmap_single(priv->pdev, info->mapping,
1619 info->skb->len, PCI_DMA_TODEVICE);
1620
1621 - memset(&txi->status, 0, sizeof(txi->status));
1622 + ieee80211_tx_info_clear_status(txi);
1623 +
1624 skb_pull(skb, sizeof(struct adm8211_tx_hdr));
1625 memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen);
1626 - if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
1627 - if (status & TDES0_STATUS_ES)
1628 - txi->status.excessive_retries = 1;
1629 - else
1630 - txi->flags |= IEEE80211_TX_STAT_ACK;
1631 - }
1632 + if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) &&
1633 + !(status & TDES0_STATUS_ES))
1634 + txi->flags |= IEEE80211_TX_STAT_ACK;
1635 +
1636 ieee80211_tx_status_irqsafe(dev, skb);
1637
1638 info->skb = NULL;
1639 @@ -1691,8 +1690,10 @@ static int adm8211_tx(struct ieee80211_h
1640 struct ieee80211_hdr *hdr;
1641 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1642 struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info);
1643 + u8 rc_flags;
1644
1645 - short_preamble = !!(txrate->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE);
1646 + rc_flags = info->control.rates[0].flags;
1647 + short_preamble = !!(rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
1648 plcp_signal = txrate->bitrate;
1649
1650 hdr = (struct ieee80211_hdr *)skb->data;
1651 @@ -1724,10 +1725,10 @@ static int adm8211_tx(struct ieee80211_h
1652 if (short_preamble)
1653 txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE);
1654
1655 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
1656 + if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
1657 txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS);
1658
1659 - txhdr->retry_limit = info->control.retry_limit;
1660 + txhdr->retry_limit = info->control.rates[0].count;
1661
1662 adm8211_tx_raw(dev, skb, plcp_signal, hdrlen);
1663
1664 --- a/drivers/net/wireless/ath5k/base.c
1665 +++ b/drivers/net/wireless/ath5k/base.c
1666 @@ -542,8 +542,8 @@ ath5k_pci_probe(struct pci_dev *pdev,
1667
1668 /* set up multi-rate retry capabilities */
1669 if (sc->ah->ah_version == AR5K_AR5212) {
1670 - hw->max_altrates = 3;
1671 - hw->max_altrate_tries = 11;
1672 + hw->max_rates = 4;
1673 + hw->max_rate_tries = 11;
1674 }
1675
1676 /* Finish private driver data initialization */
1677 @@ -1188,7 +1188,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc
1678 ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,
1679 (sc->power_level * 2),
1680 ieee80211_get_tx_rate(sc->hw, info)->hw_value,
1681 - info->control.retry_limit, keyidx, 0, flags, 0, 0);
1682 + info->control.rates[0].count, keyidx, 0, flags, 0, 0);
1683 if (ret)
1684 goto err_unmap;
1685
1686 @@ -1200,7 +1200,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc
1687 break;
1688
1689 mrr_rate[i] = rate->hw_value;
1690 - mrr_tries[i] = info->control.retries[i].limit;
1691 + mrr_tries[i] = info->control.rates[i + 1].count;
1692 }
1693
1694 ah->ah_setup_mrr_tx_desc(ah, ds,
1695 @@ -1846,30 +1846,26 @@ ath5k_tx_processq(struct ath5k_softc *sc
1696 pci_unmap_single(sc->pdev, bf->skbaddr, skb->len,
1697 PCI_DMA_TODEVICE);
1698
1699 - memset(&info->status, 0, sizeof(info->status));
1700 - info->tx_rate_idx = ath5k_hw_to_driver_rix(sc,
1701 - ts.ts_rate[ts.ts_final_idx]);
1702 - info->status.retry_count = ts.ts_longretry;
1703 -
1704 + ieee80211_tx_info_clear_status(info);
1705 for (i = 0; i < 4; i++) {
1706 - struct ieee80211_tx_altrate *r =
1707 - &info->status.retries[i];
1708 + struct ieee80211_tx_rate *r =
1709 + &info->status.rates[i];
1710
1711 if (ts.ts_rate[i]) {
1712 - r->rate_idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]);
1713 - r->limit = ts.ts_retry[i];
1714 + r->idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]);
1715 + r->count = ts.ts_retry[i];
1716 } else {
1717 - r->rate_idx = -1;
1718 - r->limit = 0;
1719 + r->idx = -1;
1720 + r->count = 0;
1721 }
1722 }
1723
1724 - info->status.excessive_retries = 0;
1725 + /* count the successful attempt as well */
1726 + info->status.rates[ts.ts_final_idx].count++;
1727 +
1728 if (unlikely(ts.ts_status)) {
1729 sc->ll_stats.dot11ACKFailureCount++;
1730 - if (ts.ts_status & AR5K_TXERR_XRETRY)
1731 - info->status.excessive_retries = 1;
1732 - else if (ts.ts_status & AR5K_TXERR_FILT)
1733 + if (ts.ts_status & AR5K_TXERR_FILT)
1734 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
1735 } else {
1736 info->flags |= IEEE80211_TX_STAT_ACK;
1737 --- a/drivers/net/wireless/ath9k/main.c
1738 +++ b/drivers/net/wireless/ath9k/main.c
1739 @@ -461,12 +461,13 @@ void ath_tx_complete(struct ath_softc *s
1740 DPRINTF(sc, ATH_DBG_XMIT,
1741 "%s: TX complete: skb: %p\n", __func__, skb);
1742
1743 + ieee80211_tx_info_clear_status(tx_info);
1744 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
1745 tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
1746 - /* free driver's private data area of tx_info */
1747 - if (tx_info->driver_data[0] != NULL)
1748 - kfree(tx_info->driver_data[0]);
1749 - tx_info->driver_data[0] = NULL;
1750 + /* free driver's private data area of tx_info, XXX: HACK! */
1751 + if (tx_info->control.vif != NULL)
1752 + kfree(tx_info->control.vif);
1753 + tx_info->control.vif = NULL;
1754 }
1755
1756 if (tx_status->flags & ATH_TX_BAR) {
1757 @@ -474,17 +475,12 @@ void ath_tx_complete(struct ath_softc *s
1758 tx_status->flags &= ~ATH_TX_BAR;
1759 }
1760
1761 - if (tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY)) {
1762 - if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
1763 - /* Frame was not ACKed, but an ACK was expected */
1764 - tx_info->status.excessive_retries = 1;
1765 - }
1766 - } else {
1767 + if (!(tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY))) {
1768 /* Frame was ACKed */
1769 tx_info->flags |= IEEE80211_TX_STAT_ACK;
1770 }
1771
1772 - tx_info->status.retry_count = tx_status->retries;
1773 + tx_info->status.rates[0].count = tx_status->retries + 1;
1774
1775 ieee80211_tx_status(hw, skb);
1776 if (an)
1777 --- a/drivers/net/wireless/ath9k/rc.c
1778 +++ b/drivers/net/wireless/ath9k/rc.c
1779 @@ -1864,24 +1864,21 @@ static void ath_tx_status(void *priv, st
1780
1781 hdr = (struct ieee80211_hdr *)skb->data;
1782 fc = hdr->frame_control;
1783 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1784 + /* XXX: UGLY HACK!! */
1785 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1786
1787 spin_lock_bh(&sc->node_lock);
1788 an = ath_node_find(sc, hdr->addr1);
1789 spin_unlock_bh(&sc->node_lock);
1790
1791 - if (!an || !priv_sta || !ieee80211_is_data(fc)) {
1792 - if (tx_info->driver_data[0] != NULL) {
1793 - kfree(tx_info->driver_data[0]);
1794 - tx_info->driver_data[0] = NULL;
1795 - }
1796 + if (tx_info_priv == NULL)
1797 return;
1798 - }
1799 - if (tx_info->driver_data[0] != NULL) {
1800 +
1801 + if (an && priv_sta && ieee80211_is_data(fc))
1802 ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
1803 - kfree(tx_info->driver_data[0]);
1804 - tx_info->driver_data[0] = NULL;
1805 - }
1806 +
1807 + kfree(tx_info_priv);
1808 + tx_info->control.vif = NULL;
1809 }
1810
1811 static void ath_tx_aggr_resp(struct ath_softc *sc,
1812 @@ -1927,10 +1924,11 @@ static void ath_tx_aggr_resp(struct ath_
1813 }
1814 }
1815
1816 -static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1817 - struct ieee80211_sta *sta, void *priv_sta,
1818 - struct sk_buff *skb, struct rate_selection *sel)
1819 +static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1820 + struct ieee80211_tx_rate_control *txrc)
1821 {
1822 + struct ieee80211_supported_band *sband = txrc->sband;
1823 + struct sk_buff *skb = txrc->skb;
1824 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1825 struct ath_softc *sc = priv;
1826 struct ieee80211_hw *hw = sc->hw;
1827 @@ -1946,17 +1944,17 @@ static void ath_get_rate(void *priv, str
1828
1829 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
1830
1831 - /* allocate driver private area of tx_info */
1832 - tx_info->driver_data[0] = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
1833 - ASSERT(tx_info->driver_data[0] != NULL);
1834 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1835 + /* allocate driver private area of tx_info, XXX: UGLY HACK! */
1836 + tx_info->control.vif = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
1837 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1838 + ASSERT(tx_info_priv != NULL);
1839
1840 lowest_idx = rate_lowest_index(sband, sta);
1841 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
1842 /* lowest rate for management and multicast/broadcast frames */
1843 if (!ieee80211_is_data(fc) ||
1844 is_multicast_ether_addr(hdr->addr1) || !sta) {
1845 - sel->rate_idx = lowest_idx;
1846 + tx_info->control.rates[0].idx = lowest_idx;
1847 return;
1848 }
1849
1850 @@ -1967,8 +1965,10 @@ static void ath_get_rate(void *priv, str
1851 tx_info_priv->rcs,
1852 &is_probe,
1853 false);
1854 +#if 0
1855 if (is_probe)
1856 sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
1857 +#endif
1858
1859 /* Ratecontrol sometimes returns invalid rate index */
1860 if (tx_info_priv->rcs[0].rix != 0xff)
1861 @@ -1976,7 +1976,7 @@ static void ath_get_rate(void *priv, str
1862 else
1863 tx_info_priv->rcs[0].rix = ath_rc_priv->prev_data_rix;
1864
1865 - sel->rate_idx = tx_info_priv->rcs[0].rix;
1866 + tx_info->control.rates[0].idx = tx_info_priv->rcs[0].rix;
1867
1868 /* Check if aggregation has to be enabled for this tid */
1869
1870 --- a/drivers/net/wireless/ath9k/xmit.c
1871 +++ b/drivers/net/wireless/ath9k/xmit.c
1872 @@ -168,7 +168,9 @@ static void fill_min_rates(struct sk_buf
1873
1874 hdr = (struct ieee80211_hdr *)skb->data;
1875 fc = hdr->frame_control;
1876 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1877 +
1878 + /* XXX: HACK! */
1879 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1880
1881 if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) {
1882 txctl->use_minrate = 1;
1883 @@ -288,13 +290,16 @@ static int ath_tx_prepare(struct ath_sof
1884
1885 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
1886 txctl->flags |= ATH9K_TXDESC_NOACK;
1887 - if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
1888 +
1889 + if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1890 txctl->flags |= ATH9K_TXDESC_RTSENA;
1891
1892 /*
1893 * Setup for rate calculations.
1894 */
1895 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1896 +
1897 + /* XXX: HACK! */
1898 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1899 rcs = tx_info_priv->rcs;
1900
1901 if (ieee80211_is_data(fc) && !txctl->use_minrate) {
1902 @@ -854,7 +859,9 @@ static int ath_tx_send_normal(struct ath
1903
1904 skb = (struct sk_buff *)bf->bf_mpdu;
1905 tx_info = IEEE80211_SKB_CB(skb);
1906 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1907 +
1908 + /* XXX: HACK! */
1909 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1910 memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
1911
1912 /* update starting sequence number for subsequent ADDBA request */
1913 @@ -1248,8 +1255,9 @@ static int ath_tx_processq(struct ath_so
1914 }
1915 skb = bf->bf_mpdu;
1916 tx_info = IEEE80211_SKB_CB(skb);
1917 - tx_info_priv = (struct ath_tx_info_priv *)
1918 - tx_info->driver_data[0];
1919 +
1920 + /* XXX: HACK! */
1921 + tx_info_priv = (struct ath_tx_info_priv *) tx_info->control.vif;
1922 if (ds->ds_txstat.ts_status & ATH9K_TXERR_FILT)
1923 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
1924 if ((ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) == 0 &&
1925 @@ -1430,7 +1438,8 @@ static int ath_tx_send_ampdu(struct ath_
1926
1927 skb = (struct sk_buff *)bf->bf_mpdu;
1928 tx_info = IEEE80211_SKB_CB(skb);
1929 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1930 + /* XXX: HACK! */
1931 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1932 memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
1933
1934 /* Add sub-frame to BAW */
1935 @@ -1464,7 +1473,7 @@ static u32 ath_lookup_rate(struct ath_so
1936 skb = (struct sk_buff *)bf->bf_mpdu;
1937 tx_info = IEEE80211_SKB_CB(skb);
1938 tx_info_priv = (struct ath_tx_info_priv *)
1939 - tx_info->driver_data[0];
1940 + tx_info->control.vif; /* XXX: HACK! */
1941 memcpy(bf->bf_rcs,
1942 tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
1943
1944 @@ -1924,7 +1933,8 @@ static int ath_tx_start_dma(struct ath_s
1945
1946 bf->bf_flags = txctl->flags;
1947 bf->bf_keytype = txctl->keytype;
1948 - tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1949 + /* XXX: HACK! */
1950 + tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1951 rcs = tx_info_priv->rcs;
1952 bf->bf_rcs[0] = rcs[0];
1953 bf->bf_rcs[1] = rcs[1];
1954 --- a/drivers/net/wireless/b43/dma.c
1955 +++ b/drivers/net/wireless/b43/dma.c
1956 @@ -1387,13 +1387,13 @@ void b43_dma_handle_txstatus(struct b43_
1957
1958 info = IEEE80211_SKB_CB(meta->skb);
1959
1960 - memset(&info->status, 0, sizeof(info->status));
1961 + ieee80211_tx_info_clear_status(info);
1962
1963 /*
1964 * Call back to inform the ieee80211 subsystem about
1965 * the status of the transmission.
1966 */
1967 - frame_succeed = b43_fill_txstatus_report(info, status);
1968 + frame_succeed = b43_fill_txstatus_report(dev, info, status);
1969 #ifdef CONFIG_B43_DEBUG
1970 if (frame_succeed)
1971 ring->nr_succeed_tx_packets++;
1972 --- a/drivers/net/wireless/b43/main.c
1973 +++ b/drivers/net/wireless/b43/main.c
1974 @@ -4563,7 +4563,7 @@ static int b43_wireless_init(struct ssb_
1975 BIT(NL80211_IFTYPE_ADHOC);
1976
1977 hw->queues = b43_modparam_qos ? 4 : 1;
1978 - hw->max_altrates = 1;
1979 + hw->max_rates = 2;
1980 SET_IEEE80211_DEV(hw, dev->dev);
1981 if (is_valid_ether_addr(sprom->et1mac))
1982 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
1983 --- a/drivers/net/wireless/b43/pio.c
1984 +++ b/drivers/net/wireless/b43/pio.c
1985 @@ -587,9 +587,9 @@ void b43_pio_handle_txstatus(struct b43_
1986 spin_lock(&q->lock); /* IRQs are already disabled. */
1987
1988 info = IEEE80211_SKB_CB(pack->skb);
1989 - memset(&info->status, 0, sizeof(info->status));
1990 + ieee80211_tx_info_clear_status(info);
1991
1992 - b43_fill_txstatus_report(info, status);
1993 + b43_fill_txstatus_report(dev, info, status);
1994
1995 total_len = pack->skb->len + b43_txhdr_size(dev);
1996 total_len = roundup(total_len, 4);
1997 --- a/drivers/net/wireless/b43/xmit.c
1998 +++ b/drivers/net/wireless/b43/xmit.c
1999 @@ -185,7 +185,7 @@ int b43_generate_txhdr(struct b43_wldev
2000 u8 *_txhdr,
2001 const unsigned char *fragment_data,
2002 unsigned int fragment_len,
2003 - const struct ieee80211_tx_info *info,
2004 + struct ieee80211_tx_info *info,
2005 u16 cookie)
2006 {
2007 struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr;
2008 @@ -202,6 +202,7 @@ int b43_generate_txhdr(struct b43_wldev
2009 u16 phy_ctl = 0;
2010 u8 extra_ft = 0;
2011 struct ieee80211_rate *txrate;
2012 + struct ieee80211_tx_rate *rates;
2013
2014 memset(txhdr, 0, sizeof(*txhdr));
2015
2016 @@ -291,7 +292,7 @@ int b43_generate_txhdr(struct b43_wldev
2017 phy_ctl |= B43_TXH_PHY_ENC_OFDM;
2018 else
2019 phy_ctl |= B43_TXH_PHY_ENC_CCK;
2020 - if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE)
2021 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
2022 phy_ctl |= B43_TXH_PHY_SHORTPRMBL;
2023
2024 switch (b43_ieee80211_antenna_sanitize(dev, info->antenna_sel_tx)) {
2025 @@ -314,6 +315,7 @@ int b43_generate_txhdr(struct b43_wldev
2026 B43_WARN_ON(1);
2027 }
2028
2029 + rates = info->control.rates;
2030 /* MAC control */
2031 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
2032 mac_ctl |= B43_TXH_MAC_ACK;
2033 @@ -324,12 +326,22 @@ int b43_generate_txhdr(struct b43_wldev
2034 mac_ctl |= B43_TXH_MAC_STMSDU;
2035 if (phy->type == B43_PHYTYPE_A)
2036 mac_ctl |= B43_TXH_MAC_5GHZ;
2037 - if (info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT)
2038 +
2039 + /* Overwrite rates[0].count to make the retry calculation
2040 + * in the tx status easier. need the actual retry limit to
2041 + * detect whether the fallback rate was used.
2042 + */
2043 + if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
2044 + (rates[0].count <= dev->wl->hw->conf.long_frame_max_tx_count)) {
2045 + rates[0].count = dev->wl->hw->conf.long_frame_max_tx_count;
2046 mac_ctl |= B43_TXH_MAC_LONGFRAME;
2047 + } else {
2048 + rates[0].count = dev->wl->hw->conf.short_frame_max_tx_count;
2049 + }
2050
2051 /* Generate the RTS or CTS-to-self frame */
2052 - if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
2053 - (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) {
2054 + if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
2055 + (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) {
2056 unsigned int len;
2057 struct ieee80211_hdr *hdr;
2058 int rts_rate, rts_rate_fb;
2059 @@ -344,7 +356,7 @@ int b43_generate_txhdr(struct b43_wldev
2060 rts_rate_fb = b43_calc_fallback_rate(rts_rate);
2061 rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb);
2062
2063 - if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2064 + if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2065 struct ieee80211_cts *cts;
2066
2067 if (b43_is_old_txhdr_format(dev)) {
2068 @@ -687,10 +699,18 @@ void b43_handle_txstatus(struct b43_wlde
2069 /* Fill out the mac80211 TXstatus report based on the b43-specific
2070 * txstatus report data. This returns a boolean whether the frame was
2071 * successfully transmitted. */
2072 -bool b43_fill_txstatus_report(struct ieee80211_tx_info *report,
2073 +bool b43_fill_txstatus_report(struct b43_wldev *dev,
2074 + struct ieee80211_tx_info *report,
2075 const struct b43_txstatus *status)
2076 {
2077 bool frame_success = 1;
2078 + int retry_limit;
2079 +
2080 + /* preserve the confiured retry limit before clearing the status
2081 + * The xmit function has overwritten the rc's value with the actual
2082 + * retry limit done by the hardware */
2083 + retry_limit = report->status.rates[0].count;
2084 + ieee80211_tx_info_clear_status(report);
2085
2086 if (status->acked) {
2087 /* The frame was ACKed. */
2088 @@ -700,14 +720,32 @@ bool b43_fill_txstatus_report(struct iee
2089 if (!(report->flags & IEEE80211_TX_CTL_NO_ACK)) {
2090 /* ...but we expected an ACK. */
2091 frame_success = 0;
2092 - report->status.excessive_retries = 1;
2093 }
2094 }
2095 if (status->frame_count == 0) {
2096 /* The frame was not transmitted at all. */
2097 - report->status.retry_count = 0;
2098 - } else
2099 - report->status.retry_count = status->frame_count - 1;
2100 + report->status.rates[0].count = 0;
2101 + } else if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
2102 + /*
2103 + * If the short retries (RTS, not data frame) have exceeded
2104 + * the limit, the hw will not have tried the selected rate,
2105 + * but will have used the fallback rate instead.
2106 + * Don't let the rate control count attempts for the selected
2107 + * rate in this case, otherwise the statistics will be off.
2108 + */
2109 + report->status.rates[0].count = 0;
2110 + report->status.rates[1].count = status->frame_count;
2111 + } else {
2112 + if (status->frame_count > retry_limit) {
2113 + report->status.rates[0].count = retry_limit;
2114 + report->status.rates[1].count = status->frame_count -
2115 + retry_limit;
2116 +
2117 + } else {
2118 + report->status.rates[0].count = status->frame_count;
2119 + report->status.rates[1].idx = -1;
2120 + }
2121 + }
2122
2123 return frame_success;
2124 }
2125 --- a/drivers/net/wireless/b43/xmit.h
2126 +++ b/drivers/net/wireless/b43/xmit.h
2127 @@ -178,7 +178,7 @@ int b43_generate_txhdr(struct b43_wldev
2128 u8 * txhdr,
2129 const unsigned char *fragment_data,
2130 unsigned int fragment_len,
2131 - const struct ieee80211_tx_info *txctl, u16 cookie);
2132 + struct ieee80211_tx_info *txctl, u16 cookie);
2133
2134 /* Transmit Status */
2135 struct b43_txstatus {
2136 @@ -294,7 +294,8 @@ void b43_rx(struct b43_wldev *dev, struc
2137
2138 void b43_handle_txstatus(struct b43_wldev *dev,
2139 const struct b43_txstatus *status);
2140 -bool b43_fill_txstatus_report(struct ieee80211_tx_info *report,
2141 +bool b43_fill_txstatus_report(struct b43_wldev *dev,
2142 + struct ieee80211_tx_info *report,
2143 const struct b43_txstatus *status);
2144
2145 void b43_tx_suspend(struct b43_wldev *dev);
2146 --- a/drivers/net/wireless/b43legacy/dma.c
2147 +++ b/drivers/net/wireless/b43legacy/dma.c
2148 @@ -1411,6 +1411,7 @@ void b43legacy_dma_handle_txstatus(struc
2149 struct b43legacy_dmaring *ring;
2150 struct b43legacy_dmadesc_generic *desc;
2151 struct b43legacy_dmadesc_meta *meta;
2152 + int retry_limit;
2153 int slot;
2154
2155 ring = parse_cookie(dev, status->cookie, &slot);
2156 @@ -1437,25 +1438,42 @@ void b43legacy_dma_handle_txstatus(struc
2157 struct ieee80211_tx_info *info;
2158 BUG_ON(!meta->skb);
2159 info = IEEE80211_SKB_CB(meta->skb);
2160 - /* Call back to inform the ieee80211 subsystem about the
2161 - * status of the transmission.
2162 - * Some fields of txstat are already filled in dma_tx().
2163 - */
2164
2165 - memset(&info->status, 0, sizeof(info->status));
2166 + /* preserve the confiured retry limit before clearing the status
2167 + * The xmit function has overwritten the rc's value with the actual
2168 + * retry limit done by the hardware */
2169 + retry_limit = info->status.rates[0].count;
2170 + ieee80211_tx_info_clear_status(info);
2171
2172 - if (status->acked) {
2173 + if (status->acked)
2174 info->flags |= IEEE80211_TX_STAT_ACK;
2175 +
2176 + if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
2177 + /*
2178 + * If the short retries (RTS, not data frame) have exceeded
2179 + * the limit, the hw will not have tried the selected rate,
2180 + * but will have used the fallback rate instead.
2181 + * Don't let the rate control count attempts for the selected
2182 + * rate in this case, otherwise the statistics will be off.
2183 + */
2184 + info->status.rates[0].count = 0;
2185 + info->status.rates[1].count = status->frame_count;
2186 } else {
2187 - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
2188 - info->status.excessive_retries = 1;
2189 + if (status->frame_count > retry_limit) {
2190 + info->status.rates[0].count = retry_limit;
2191 + info->status.rates[1].count = status->frame_count -
2192 + retry_limit;
2193 +
2194 + } else {
2195 + info->status.rates[0].count = status->frame_count;
2196 + info->status.rates[1].idx = -1;
2197 + }
2198 }
2199 - if (status->frame_count == 0) {
2200 - /* The frame was not transmitted at all. */
2201 - info->status.retry_count = 0;
2202 - } else
2203 - info->status.retry_count = status->frame_count
2204 - - 1;
2205 +
2206 + /* Call back to inform the ieee80211 subsystem about the
2207 + * status of the transmission.
2208 + * Some fields of txstat are already filled in dma_tx().
2209 + */
2210 ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb);
2211 /* skb is freed by ieee80211_tx_status_irqsafe() */
2212 meta->skb = NULL;
2213 --- a/drivers/net/wireless/b43legacy/main.c
2214 +++ b/drivers/net/wireless/b43legacy/main.c
2215 @@ -3691,7 +3691,7 @@ static int b43legacy_wireless_init(struc
2216 BIT(NL80211_IFTYPE_WDS) |
2217 BIT(NL80211_IFTYPE_ADHOC);
2218 hw->queues = 1; /* FIXME: hardware has more queues */
2219 - hw->max_altrates = 1;
2220 + hw->max_rates = 2;
2221 SET_IEEE80211_DEV(hw, dev->dev);
2222 if (is_valid_ether_addr(sprom->et1mac))
2223 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
2224 --- a/drivers/net/wireless/b43legacy/pio.c
2225 +++ b/drivers/net/wireless/b43legacy/pio.c
2226 @@ -491,6 +491,7 @@ void b43legacy_pio_handle_txstatus(struc
2227 struct b43legacy_pioqueue *queue;
2228 struct b43legacy_pio_txpacket *packet;
2229 struct ieee80211_tx_info *info;
2230 + int retry_limit;
2231
2232 queue = parse_cookie(dev, status->cookie, &packet);
2233 B43legacy_WARN_ON(!queue);
2234 @@ -503,11 +504,37 @@ void b43legacy_pio_handle_txstatus(struc
2235 sizeof(struct b43legacy_txhdr_fw3));
2236
2237 info = IEEE80211_SKB_CB(packet->skb);
2238 - memset(&info->status, 0, sizeof(info->status));
2239 +
2240 + /* preserve the confiured retry limit before clearing the status
2241 + * The xmit function has overwritten the rc's value with the actual
2242 + * retry limit done by the hardware */
2243 + retry_limit = info->status.rates[0].count;
2244 + ieee80211_tx_info_clear_status(info);
2245
2246 if (status->acked)
2247 info->flags |= IEEE80211_TX_STAT_ACK;
2248 - info->status.retry_count = status->frame_count - 1;
2249 +
2250 + if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
2251 + /*
2252 + * If the short retries (RTS, not data frame) have exceeded
2253 + * the limit, the hw will not have tried the selected rate,
2254 + * but will have used the fallback rate instead.
2255 + * Don't let the rate control count attempts for the selected
2256 + * rate in this case, otherwise the statistics will be off.
2257 + */
2258 + info->status.rates[0].count = 0;
2259 + info->status.rates[1].count = status->frame_count;
2260 + } else {
2261 + if (status->frame_count > retry_limit) {
2262 + info->status.rates[0].count = retry_limit;
2263 + info->status.rates[1].count = status->frame_count -
2264 + retry_limit;
2265 +
2266 + } else {
2267 + info->status.rates[0].count = status->frame_count;
2268 + info->status.rates[1].idx = -1;
2269 + }
2270 + }
2271 ieee80211_tx_status_irqsafe(dev->wl->hw, packet->skb);
2272 packet->skb = NULL;
2273
2274 --- a/drivers/net/wireless/b43legacy/xmit.c
2275 +++ b/drivers/net/wireless/b43legacy/xmit.c
2276 @@ -188,7 +188,7 @@ static int generate_txhdr_fw3(struct b43
2277 struct b43legacy_txhdr_fw3 *txhdr,
2278 const unsigned char *fragment_data,
2279 unsigned int fragment_len,
2280 - const struct ieee80211_tx_info *info,
2281 + struct ieee80211_tx_info *info,
2282 u16 cookie)
2283 {
2284 const struct ieee80211_hdr *wlhdr;
2285 @@ -201,6 +201,7 @@ static int generate_txhdr_fw3(struct b43
2286 u32 mac_ctl = 0;
2287 u16 phy_ctl = 0;
2288 struct ieee80211_rate *tx_rate;
2289 + struct ieee80211_tx_rate *rates;
2290
2291 wlhdr = (const struct ieee80211_hdr *)fragment_data;
2292
2293 @@ -274,7 +275,7 @@ static int generate_txhdr_fw3(struct b43
2294 /* PHY TX Control word */
2295 if (rate_ofdm)
2296 phy_ctl |= B43legacy_TX4_PHY_OFDM;
2297 - if (dev->short_preamble)
2298 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
2299 phy_ctl |= B43legacy_TX4_PHY_SHORTPRMBL;
2300 switch (info->antenna_sel_tx) {
2301 case 0:
2302 @@ -291,6 +292,7 @@ static int generate_txhdr_fw3(struct b43
2303 }
2304
2305 /* MAC control */
2306 + rates = info->control.rates;
2307 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
2308 mac_ctl |= B43legacy_TX4_MAC_ACK;
2309 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
2310 @@ -299,12 +301,22 @@ static int generate_txhdr_fw3(struct b43
2311 mac_ctl |= B43legacy_TX4_MAC_STMSDU;
2312 if (rate_fb_ofdm)
2313 mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM;
2314 - if (info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT)
2315 +
2316 + /* Overwrite rates[0].count to make the retry calculation
2317 + * in the tx status easier. need the actual retry limit to
2318 + * detect whether the fallback rate was used.
2319 + */
2320 + if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
2321 + (rates[0].count <= dev->wl->hw->conf.long_frame_max_tx_count)) {
2322 + rates[0].count = dev->wl->hw->conf.long_frame_max_tx_count;
2323 mac_ctl |= B43legacy_TX4_MAC_LONGFRAME;
2324 + } else {
2325 + rates[0].count = dev->wl->hw->conf.short_frame_max_tx_count;
2326 + }
2327
2328 /* Generate the RTS or CTS-to-self frame */
2329 - if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
2330 - (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) {
2331 + if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
2332 + (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) {
2333 unsigned int len;
2334 struct ieee80211_hdr *hdr;
2335 int rts_rate;
2336 @@ -319,7 +331,7 @@ static int generate_txhdr_fw3(struct b43
2337 if (rts_rate_fb_ofdm)
2338 mac_ctl |= B43legacy_TX4_MAC_CTSFALLBACKOFDM;
2339
2340 - if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2341 + if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2342 ieee80211_ctstoself_get(dev->wl->hw,
2343 info->control.vif,
2344 fragment_data,
2345 @@ -362,7 +374,7 @@ int b43legacy_generate_txhdr(struct b43l
2346 u8 *txhdr,
2347 const unsigned char *fragment_data,
2348 unsigned int fragment_len,
2349 - const struct ieee80211_tx_info *info,
2350 + struct ieee80211_tx_info *info,
2351 u16 cookie)
2352 {
2353 return generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr,
2354 --- a/drivers/net/wireless/b43legacy/xmit.h
2355 +++ b/drivers/net/wireless/b43legacy/xmit.h
2356 @@ -80,7 +80,7 @@ int b43legacy_generate_txhdr(struct b43l
2357 u8 *txhdr,
2358 const unsigned char *fragment_data,
2359 unsigned int fragment_len,
2360 - const struct ieee80211_tx_info *info,
2361 + struct ieee80211_tx_info *info,
2362 u16 cookie);
2363
2364
2365 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
2366 +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
2367 @@ -422,34 +422,6 @@ static void rs_free_sta(void *priv, stru
2368 }
2369
2370
2371 -/*
2372 - * get ieee prev rate from rate scale table.
2373 - * for A and B mode we need to overright prev
2374 - * value
2375 - */
2376 -static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate)
2377 -{
2378 - int next_rate = iwl3945_get_prev_ieee_rate(rate);
2379 -
2380 - switch (priv->band) {
2381 - case IEEE80211_BAND_5GHZ:
2382 - if (rate == IWL_RATE_12M_INDEX)
2383 - next_rate = IWL_RATE_9M_INDEX;
2384 - else if (rate == IWL_RATE_6M_INDEX)
2385 - next_rate = IWL_RATE_6M_INDEX;
2386 - break;
2387 -/* XXX cannot be invoked in current mac80211 so not a regression
2388 - case MODE_IEEE80211B:
2389 - if (rate == IWL_RATE_11M_INDEX_TABLE)
2390 - next_rate = IWL_RATE_5M_INDEX_TABLE;
2391 - break;
2392 - */
2393 - default:
2394 - break;
2395 - }
2396 -
2397 - return next_rate;
2398 -}
2399 /**
2400 * rs_tx_status - Update rate control values based on Tx results
2401 *
2402 @@ -460,17 +432,21 @@ static void rs_tx_status(void *priv_rate
2403 struct ieee80211_sta *sta, void *priv_sta,
2404 struct sk_buff *skb)
2405 {
2406 - u8 retries, current_count;
2407 + u8 retries = 0, current_count;
2408 int scale_rate_index, first_index, last_index;
2409 unsigned long flags;
2410 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
2411 struct iwl3945_rs_sta *rs_sta = priv_sta;
2412 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2413 + int i;
2414
2415 IWL_DEBUG_RATE("enter\n");
2416
2417 - retries = info->status.retry_count;
2418 - first_index = sband->bitrates[info->tx_rate_idx].hw_value;
2419 + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
2420 + retries += info->status.rates[i].count;
2421 + retries--;
2422 +
2423 + first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
2424 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
2425 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index);
2426 return;
2427 @@ -502,7 +478,7 @@ static void rs_tx_status(void *priv_rate
2428 last_index = scale_rate_index;
2429 } else {
2430 current_count = priv->retry_rate;
2431 - last_index = rs_adjust_next_rate(priv,
2432 + last_index = iwl3945_rs_next_rate(priv,
2433 scale_rate_index);
2434 }
2435
2436 @@ -518,7 +494,7 @@ static void rs_tx_status(void *priv_rate
2437
2438 if (retries)
2439 scale_rate_index =
2440 - rs_adjust_next_rate(priv, scale_rate_index);
2441 + iwl3945_rs_next_rate(priv, scale_rate_index);
2442 }
2443
2444
2445 @@ -630,10 +606,11 @@ static u16 iwl3945_get_adjacent_rate(str
2446 * rate table and must reference the driver allocated rate table
2447 *
2448 */
2449 -static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
2450 - struct ieee80211_sta *sta, void *priv_sta,
2451 - struct sk_buff *skb, struct rate_selection *sel)
2452 +static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
2453 + void *priv_sta, struct ieee80211_tx_rate_control *txrc)
2454 {
2455 + struct ieee80211_supported_band *sband = txrc->sband;
2456 + struct sk_buff *skb = txrc->skb;
2457 u8 low = IWL_RATE_INVALID;
2458 u8 high = IWL_RATE_INVALID;
2459 u16 high_low;
2460 @@ -649,6 +626,7 @@ static void rs_get_rate(void *priv_r, st
2461 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2462 u16 fc, rate_mask;
2463 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r;
2464 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2465 DECLARE_MAC_BUF(mac);
2466
2467 IWL_DEBUG_RATE("enter\n");
2468 @@ -660,7 +638,7 @@ static void rs_get_rate(void *priv_r, st
2469 is_multicast_ether_addr(hdr->addr1) ||
2470 !sta || !priv_sta) {
2471 IWL_DEBUG_RATE("leave: No STA priv data to update!\n");
2472 - sel->rate_idx = rate_lowest_index(sband, sta);
2473 + info->control.rates[0].idx = rate_lowest_index(sband, sta);
2474 return;
2475 }
2476
2477 @@ -793,9 +771,10 @@ static void rs_get_rate(void *priv_r, st
2478
2479 rs_sta->last_txrate_idx = index;
2480 if (sband->band == IEEE80211_BAND_5GHZ)
2481 - sel->rate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE;
2482 + info->control.rates[0].idx = rs_sta->last_txrate_idx -
2483 + IWL_FIRST_OFDM_RATE;
2484 else
2485 - sel->rate_idx = rs_sta->last_txrate_idx;
2486 + info->control.rates[0].idx = rs_sta->last_txrate_idx;
2487
2488 IWL_DEBUG_RATE("leave: %d\n", index);
2489 }
2490 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c
2491 +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
2492 @@ -261,6 +261,35 @@ static inline const char *iwl3945_get_tx
2493 }
2494 #endif
2495
2496 +/*
2497 + * get ieee prev rate from rate scale table.
2498 + * for A and B mode we need to overright prev
2499 + * value
2500 + */
2501 +int iwl3945_rs_next_rate(struct iwl3945_priv *priv, int rate)
2502 +{
2503 + int next_rate = iwl3945_get_prev_ieee_rate(rate);
2504 +
2505 + switch (priv->band) {
2506 + case IEEE80211_BAND_5GHZ:
2507 + if (rate == IWL_RATE_12M_INDEX)
2508 + next_rate = IWL_RATE_9M_INDEX;
2509 + else if (rate == IWL_RATE_6M_INDEX)
2510 + next_rate = IWL_RATE_6M_INDEX;
2511 + break;
2512 +/* XXX cannot be invoked in current mac80211 so not a regression
2513 + case MODE_IEEE80211B:
2514 + if (rate == IWL_RATE_11M_INDEX_TABLE)
2515 + next_rate = IWL_RATE_5M_INDEX_TABLE;
2516 + break;
2517 + */
2518 + default:
2519 + break;
2520 + }
2521 +
2522 + return next_rate;
2523 +}
2524 +
2525
2526 /**
2527 * iwl3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd
2528 @@ -308,6 +337,7 @@ static void iwl3945_rx_reply_tx(struct i
2529 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
2530 u32 status = le32_to_cpu(tx_resp->status);
2531 int rate_idx;
2532 + int fail, i;
2533
2534 if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) {
2535 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
2536 @@ -318,9 +348,33 @@ static void iwl3945_rx_reply_tx(struct i
2537 }
2538
2539 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
2540 - memset(&info->status, 0, sizeof(info->status));
2541 + ieee80211_tx_info_clear_status(info);
2542 +
2543 + /* Fill the MRR chain with some info about on-chip retransmissions */
2544 + rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate);
2545 + if (info->band == IEEE80211_BAND_5GHZ)
2546 + rate_idx -= IWL_FIRST_OFDM_RATE;
2547 +
2548 + info->status.rates[0].count = tx_resp->failure_frame + 1;
2549 + fail = tx_resp->failure_frame;
2550 + for(i = 0; i < 4; i++) {
2551 + int next = iwl3945_rs_next_rate(priv, rate_idx);
2552 +
2553 + info->status.rates[i].idx = rate_idx;
2554 +
2555 + if ((rate_idx == next) || (i == 3)) {
2556 + info->status.rates[i].count = fail;
2557 + break;
2558 + }
2559 +
2560 + info->status.rates[i].count = priv->retry_rate;
2561 + fail -= priv->retry_rate;
2562 + rate_idx = next;
2563 + if (fail <= 0)
2564 + break;
2565 + }
2566 + info->status.rates[i].count++; /* add final attempt */
2567
2568 - info->status.retry_count = tx_resp->failure_frame;
2569 /* tx_status->rts_retry_count = tx_resp->failure_rts; */
2570 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ?
2571 IEEE80211_TX_STAT_ACK : 0;
2572 @@ -329,10 +383,6 @@ static void iwl3945_rx_reply_tx(struct i
2573 txq_id, iwl3945_get_tx_fail_reason(status), status,
2574 tx_resp->rate, tx_resp->failure_frame);
2575
2576 - rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate);
2577 - if (info->band == IEEE80211_BAND_5GHZ)
2578 - rate_idx -= IWL_FIRST_OFDM_RATE;
2579 - info->tx_rate_idx = rate_idx;
2580 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
2581 iwl3945_tx_queue_reclaim(priv, txq_id, index);
2582
2583 --- a/drivers/net/wireless/iwlwifi/iwl-3945.h
2584 +++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
2585 @@ -954,6 +954,8 @@ static inline int is_channel_ibss(const
2586 extern const struct iwl3945_channel_info *iwl3945_get_channel_info(
2587 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel);
2588
2589 +extern int iwl3945_rs_next_rate(struct iwl3945_priv *priv, int rate);
2590 +
2591 /* Requires full declaration of iwl3945_priv before including */
2592 #include "iwl-3945-io.h"
2593
2594 --- a/drivers/net/wireless/iwlwifi/iwl-core.c
2595 +++ b/drivers/net/wireless/iwlwifi/iwl-core.c
2596 @@ -88,26 +88,27 @@ EXPORT_SYMBOL(iwl_rates);
2597 * translate ucode response to mac80211 tx status control values
2598 */
2599 void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
2600 - struct ieee80211_tx_info *control)
2601 + struct ieee80211_tx_info *info)
2602 {
2603 int rate_index;
2604 + struct ieee80211_tx_rate *r = &info->control.rates[0];
2605
2606 - control->antenna_sel_tx =
2607 + info->antenna_sel_tx =
2608 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
2609 if (rate_n_flags & RATE_MCS_HT_MSK)
2610 - control->flags |= IEEE80211_TX_CTL_OFDM_HT;
2611 + r->flags |= IEEE80211_TX_RC_MCS;
2612 if (rate_n_flags & RATE_MCS_GF_MSK)
2613 - control->flags |= IEEE80211_TX_CTL_GREEN_FIELD;
2614 + r->flags |= IEEE80211_TX_RC_GREEN_FIELD;
2615 if (rate_n_flags & RATE_MCS_FAT_MSK)
2616 - control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH;
2617 + r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
2618 if (rate_n_flags & RATE_MCS_DUP_MSK)
2619 - control->flags |= IEEE80211_TX_CTL_DUP_DATA;
2620 + r->flags |= IEEE80211_TX_RC_DUP_DATA;
2621 if (rate_n_flags & RATE_MCS_SGI_MSK)
2622 - control->flags |= IEEE80211_TX_CTL_SHORT_GI;
2623 + r->flags |= IEEE80211_TX_RC_SHORT_GI;
2624 rate_index = iwl_hwrate_to_plcp_idx(rate_n_flags);
2625 - if (control->band == IEEE80211_BAND_5GHZ)
2626 + if (info->band == IEEE80211_BAND_5GHZ)
2627 rate_index -= IWL_FIRST_OFDM_RATE;
2628 - control->tx_rate_idx = rate_index;
2629 + r->idx = rate_index;
2630 }
2631 EXPORT_SYMBOL(iwl_hwrate_to_tx_control);
2632
2633 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
2634 +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
2635 @@ -2397,6 +2397,7 @@ static void iwl3945_build_tx_cmd_basic(s
2636 {
2637 __le16 fc = hdr->frame_control;
2638 __le32 tx_flags = cmd->cmd.tx.tx_flags;
2639 + u8 rc_flags = info->control.rates[0].flags;
2640
2641 cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
2642 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
2643 @@ -2423,10 +2424,10 @@ static void iwl3945_build_tx_cmd_basic(s
2644 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
2645 }
2646
2647 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
2648 + if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
2649 tx_flags |= TX_CMD_FLG_RTS_MSK;
2650 tx_flags &= ~TX_CMD_FLG_CTS_MSK;
2651 - } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2652 + } else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2653 tx_flags &= ~TX_CMD_FLG_RTS_MSK;
2654 tx_flags |= TX_CMD_FLG_CTS_MSK;
2655 }
2656 --- a/drivers/net/wireless/mac80211_hwsim.c
2657 +++ b/drivers/net/wireless/mac80211_hwsim.c
2658 @@ -209,7 +209,7 @@ static bool mac80211_hwsim_tx_frame(stru
2659 /* TODO: set mactime */
2660 rx_status.freq = data->channel->center_freq;
2661 rx_status.band = data->channel->band;
2662 - rx_status.rate_idx = info->tx_rate_idx;
2663 + rx_status.rate_idx = info->control.rates[0].idx;
2664 /* TODO: simulate signal strength (and optional packet drop) */
2665
2666 /* Copy skb to all enabled radios that are on the current frequency */
2667 @@ -269,13 +269,9 @@ static int mac80211_hwsim_tx(struct ieee
2668 if (txi->control.sta)
2669 hwsim_check_sta_magic(txi->control.sta);
2670
2671 - memset(&txi->status, 0, sizeof(txi->status));
2672 - if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
2673 - if (ack)
2674 - txi->flags |= IEEE80211_TX_STAT_ACK;
2675 - else
2676 - txi->status.excessive_retries = 1;
2677 - }
2678 + ieee80211_tx_info_clear_status(txi);
2679 + if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) && ack)
2680 + txi->flags |= IEEE80211_TX_STAT_ACK;
2681 ieee80211_tx_status_irqsafe(hw, skb);
2682 return NETDEV_TX_OK;
2683 }
2684 --- a/drivers/net/wireless/rtl8180_dev.c
2685 +++ b/drivers/net/wireless/rtl8180_dev.c
2686 @@ -182,15 +182,13 @@ static void rtl8180_handle_tx(struct iee
2687 skb->len, PCI_DMA_TODEVICE);
2688
2689 info = IEEE80211_SKB_CB(skb);
2690 - memset(&info->status, 0, sizeof(info->status));
2691 + ieee80211_tx_info_clear_status(info);
2692
2693 - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
2694 - if (flags & RTL818X_TX_DESC_FLAG_TX_OK)
2695 - info->flags |= IEEE80211_TX_STAT_ACK;
2696 - else
2697 - info->status.excessive_retries = 1;
2698 - }
2699 - info->status.retry_count = flags & 0xFF;
2700 + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) &&
2701 + (flags & RTL818X_TX_DESC_FLAG_TX_OK))
2702 + info->flags |= IEEE80211_TX_STAT_ACK;
2703 +
2704 + info->status.rates[0].count = (flags & 0xFF) + 1;
2705
2706 ieee80211_tx_status_irqsafe(dev, skb);
2707 if (ring->entries - skb_queue_len(&ring->queue) == 2)
2708 @@ -243,6 +241,7 @@ static int rtl8180_tx(struct ieee80211_h
2709 unsigned int idx, prio;
2710 dma_addr_t mapping;
2711 u32 tx_flags;
2712 + u8 rc_flags;
2713 u16 plcp_len = 0;
2714 __le16 rts_duration = 0;
2715
2716 @@ -261,15 +260,16 @@ static int rtl8180_tx(struct ieee80211_h
2717 tx_flags |= RTL818X_TX_DESC_FLAG_DMA |
2718 RTL818X_TX_DESC_FLAG_NO_ENC;
2719
2720 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
2721 + rc_flags = info->control.rates[0].flags;
2722 + if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
2723 tx_flags |= RTL818X_TX_DESC_FLAG_RTS;
2724 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
2725 - } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2726 + } else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2727 tx_flags |= RTL818X_TX_DESC_FLAG_CTS;
2728 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
2729 }
2730
2731 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
2732 + if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
2733 rts_duration = ieee80211_rts_duration(dev, priv->vif, skb->len,
2734 info);
2735
2736 @@ -292,9 +292,9 @@ static int rtl8180_tx(struct ieee80211_h
2737 entry->plcp_len = cpu_to_le16(plcp_len);
2738 entry->tx_buf = cpu_to_le32(mapping);
2739 entry->frame_len = cpu_to_le32(skb->len);
2740 - entry->flags2 = info->control.retries[0].rate_idx >= 0 ?
2741 + entry->flags2 = info->control.rates[1].idx >= 0 ?
2742 ieee80211_get_alt_retry_rate(dev, info, 0)->bitrate << 4 : 0;
2743 - entry->retry_limit = info->control.retry_limit;
2744 + entry->retry_limit = info->control.rates[0].count;
2745 entry->flags = cpu_to_le32(tx_flags);
2746 __skb_queue_tail(&ring->queue, skb);
2747 if (ring->entries - skb_queue_len(&ring->queue) < 2)
2748 @@ -856,7 +856,7 @@ static int __devinit rtl8180_probe(struc
2749 priv = dev->priv;
2750 priv->pdev = pdev;
2751
2752 - dev->max_altrates = 1;
2753 + dev->max_rates = 2;
2754 SET_IEEE80211_DEV(dev, &pdev->dev);
2755 pci_set_drvdata(pdev, dev);
2756
2757 --- a/drivers/net/wireless/rtl8187_dev.c
2758 +++ b/drivers/net/wireless/rtl8187_dev.c
2759 @@ -163,7 +163,7 @@ static void rtl8187_tx_cb(struct urb *ur
2760 usb_free_urb(info->driver_data[1]);
2761 skb_pull(skb, priv->is_rtl8187b ? sizeof(struct rtl8187b_tx_hdr) :
2762 sizeof(struct rtl8187_tx_hdr));
2763 - memset(&info->status, 0, sizeof(info->status));
2764 + ieee80211_tx_info_clear_status(info);
2765 info->flags |= IEEE80211_TX_STAT_ACK;
2766 ieee80211_tx_status_irqsafe(hw, skb);
2767 }
2768 @@ -192,12 +192,12 @@ static int rtl8187_tx(struct ieee80211_h
2769 flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24;
2770 if (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control))
2771 flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
2772 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
2773 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
2774 flags |= RTL818X_TX_DESC_FLAG_RTS;
2775 flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
2776 rts_dur = ieee80211_rts_duration(dev, priv->vif,
2777 skb->len, info);
2778 - } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2779 + } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2780 flags |= RTL818X_TX_DESC_FLAG_CTS;
2781 flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
2782 }
2783 @@ -208,7 +208,7 @@ static int rtl8187_tx(struct ieee80211_h
2784 hdr->flags = cpu_to_le32(flags);
2785 hdr->len = 0;
2786 hdr->rts_duration = rts_dur;
2787 - hdr->retry = cpu_to_le32(info->control.retry_limit << 8);
2788 + hdr->retry = cpu_to_le32((info->control.rates[0].count - 1) << 8);
2789 buf = hdr;
2790
2791 ep = 2;
2792 @@ -226,7 +226,7 @@ static int rtl8187_tx(struct ieee80211_h
2793 memset(hdr, 0, sizeof(*hdr));
2794 hdr->flags = cpu_to_le32(flags);
2795 hdr->rts_duration = rts_dur;
2796 - hdr->retry = cpu_to_le32(info->control.retry_limit << 8);
2797 + hdr->retry = cpu_to_le32((info->control.rates[0].count - 1) << 8);
2798 hdr->tx_duration =
2799 ieee80211_generic_frame_duration(dev, priv->vif,
2800 skb->len, txrate);
2801 --- a/drivers/net/wireless/p54/p54common.c
2802 +++ b/drivers/net/wireless/p54/p54common.c
2803 @@ -577,7 +577,7 @@ static void p54_rx_frame_sent(struct iee
2804 __skb_unlink(entry, &priv->tx_queue);
2805 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
2806
2807 - memset(&info->status, 0, sizeof(info->status));
2808 + ieee80211_tx_info_clear_status(info);
2809 entry_hdr = (struct p54_control_hdr *) entry->data;
2810 entry_data = (struct p54_tx_control_allocdata *) entry_hdr->data;
2811 if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0)
2812 @@ -587,10 +587,8 @@ static void p54_rx_frame_sent(struct iee
2813 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
2814 if (!(payload->status & 0x01))
2815 info->flags |= IEEE80211_TX_STAT_ACK;
2816 - else
2817 - info->status.excessive_retries = 1;
2818 }
2819 - info->status.retry_count = payload->retries - 1;
2820 + info->status.rates[0].count = payload->retries;
2821 info->status.ack_signal = p54_rssi_to_dbm(dev,
2822 le16_to_cpu(payload->ack_rssi));
2823 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
2824 @@ -816,6 +814,7 @@ static int p54_tx(struct ieee80211_hw *d
2825 size_t padding, len;
2826 u8 rate;
2827 u8 cts_rate = 0x20;
2828 + u8 rc_flags;
2829
2830 current_queue = &priv->tx_stats[skb_get_queue_mapping(skb) + 4];
2831 if (unlikely(current_queue->len > current_queue->limit))
2832 @@ -838,18 +837,19 @@ static int p54_tx(struct ieee80211_hw *d
2833 hdr->magic1 = cpu_to_le16(0x0010);
2834 hdr->len = cpu_to_le16(len);
2835 hdr->type = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le16(1);
2836 - hdr->retry1 = hdr->retry2 = info->control.retry_limit;
2837 + hdr->retry1 = hdr->retry2 = info->control.rates[0].count;
2838
2839 /* TODO: add support for alternate retry TX rates */
2840 rate = ieee80211_get_tx_rate(dev, info)->hw_value;
2841 - if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) {
2842 + rc_flags = info->control.rates[0].flags;
2843 + if (rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) {
2844 rate |= 0x10;
2845 cts_rate |= 0x10;
2846 }
2847 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
2848 + if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
2849 rate |= 0x40;
2850 cts_rate |= ieee80211_get_rts_cts_rate(dev, info)->hw_value;
2851 - } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2852 + } else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2853 rate |= 0x20;
2854 cts_rate |= ieee80211_get_rts_cts_rate(dev, info)->hw_value;
2855 }
2856 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c
2857 +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
2858 @@ -619,10 +619,10 @@ static void iwl4965_gain_computation(str
2859 static void iwl4965_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
2860 __le32 *tx_flags)
2861 {
2862 - if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
2863 + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
2864 *tx_flags |= TX_CMD_FLG_RTS_MSK;
2865 *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
2866 - } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
2867 + } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
2868 *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
2869 *tx_flags |= TX_CMD_FLG_CTS_MSK;
2870 }
2871 @@ -2070,7 +2070,7 @@ static int iwl4965_tx_status_reply_tx(st
2872 agg->frame_count, agg->start_idx, idx);
2873
2874 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
2875 - info->status.retry_count = tx_resp->failure_frame;
2876 + info->status.rates[0].count = tx_resp->failure_frame + 1;
2877 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
2878 info->flags |= iwl_is_tx_success(status)?
2879 IEEE80211_TX_STAT_ACK : 0;
2880 @@ -2227,7 +2227,7 @@ static void iwl4965_rx_reply_tx(struct i
2881 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
2882 }
2883 } else {
2884 - info->status.retry_count = tx_resp->failure_frame;
2885 + info->status.rates[0].count = tx_resp->failure_frame + 1;
2886 info->flags |=
2887 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
2888 iwl_hwrate_to_tx_control(priv,
2889 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c
2890 +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
2891 @@ -390,8 +390,8 @@ static void iwl5000_chain_noise_reset(st
2892 static void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
2893 __le32 *tx_flags)
2894 {
2895 - if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
2896 - (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT))
2897 + if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
2898 + (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
2899 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
2900 else
2901 *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
2902 @@ -1136,7 +1136,7 @@ static int iwl5000_tx_status_reply_tx(st
2903 agg->frame_count, agg->start_idx, idx);
2904
2905 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
2906 - info->status.retry_count = tx_resp->failure_frame;
2907 + info->status.rates[0].count = tx_resp->failure_frame + 1;
2908 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
2909 info->flags |= iwl_is_tx_success(status)?
2910 IEEE80211_TX_STAT_ACK : 0;
2911 @@ -1289,7 +1289,7 @@ static void iwl5000_rx_reply_tx(struct i
2912 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
2913 }
2914 } else {
2915 - info->status.retry_count = tx_resp->failure_frame;
2916 + info->status.rates[0].count = tx_resp->failure_frame + 1;
2917 info->flags =
2918 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
2919 iwl_hwrate_to_tx_control(priv,
2920 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
2921 +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
2922 @@ -800,7 +800,7 @@ static void rs_tx_status(void *priv_r, s
2923 !(info->flags & IEEE80211_TX_STAT_AMPDU))
2924 return;
2925
2926 - retries = info->status.retry_count;
2927 + retries = info->status.rates[0].count + 1;
2928
2929 if (retries > 15)
2930 retries = 15;
2931 @@ -832,20 +832,15 @@ static void rs_tx_status(void *priv_r, s
2932 if (priv->band == IEEE80211_BAND_5GHZ)
2933 rs_index -= IWL_FIRST_OFDM_RATE;
2934
2935 - if ((info->tx_rate_idx < 0) ||
2936 - (tbl_type.is_SGI ^
2937 - !!(info->flags & IEEE80211_TX_CTL_SHORT_GI)) ||
2938 - (tbl_type.is_fat ^
2939 - !!(info->flags & IEEE80211_TX_CTL_40_MHZ_WIDTH)) ||
2940 - (tbl_type.is_dup ^
2941 - !!(info->flags & IEEE80211_TX_CTL_DUP_DATA)) ||
2942 - (tbl_type.ant_type ^ info->antenna_sel_tx) ||
2943 - (!!(tx_rate & RATE_MCS_HT_MSK) ^
2944 - !!(info->flags & IEEE80211_TX_CTL_OFDM_HT)) ||
2945 - (!!(tx_rate & RATE_MCS_GF_MSK) ^
2946 - !!(info->flags & IEEE80211_TX_CTL_GREEN_FIELD)) ||
2947 + if ((info->status.rates[0].idx < 0) ||
2948 + (tbl_type.is_SGI != !!(info->status.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)) ||
2949 + (tbl_type.is_fat != !!(info->status.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)) ||
2950 + (tbl_type.is_dup != !!(info->status.rates[0].flags & IEEE80211_TX_RC_DUP_DATA)) ||
2951 + (tbl_type.ant_type != info->antenna_sel_tx) ||
2952 + (!!(tx_rate & RATE_MCS_HT_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_MCS)) ||
2953 + (!!(tx_rate & RATE_MCS_GF_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)) ||
2954 (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate !=
2955 - hw->wiphy->bands[info->band]->bitrates[info->tx_rate_idx].bitrate)) {
2956 + hw->wiphy->bands[info->band]->bitrates[info->status.rates[0].idx].bitrate)) {
2957 IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate);
2958 goto out;
2959 }
2960 @@ -2103,15 +2098,17 @@ static void rs_initialize_lq(struct iwl_
2961 return;
2962 }
2963
2964 -static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
2965 - struct ieee80211_sta *sta, void *priv_sta,
2966 - struct sk_buff *skb, struct rate_selection *sel)
2967 +static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2968 + struct ieee80211_tx_rate_control *txrc)
2969 {
2970
2971 int i;
2972 + struct sk_buff *skb = txrc->skb;
2973 + struct ieee80211_supported_band *sband = txrc->sband;
2974 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
2975 struct ieee80211_conf *conf = &priv->hw->conf;
2976 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2977 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2978 __le16 fc;
2979 struct iwl_lq_sta *lq_sta;
2980
2981 @@ -2122,7 +2119,7 @@ static void rs_get_rate(void *priv_r, st
2982 fc = hdr->frame_control;
2983 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) ||
2984 !sta || !priv_sta) {
2985 - sel->rate_idx = rate_lowest_index(sband, sta);
2986 + info->control.rates[0].idx = rate_lowest_index(sband, sta);
2987 return;
2988 }
2989
2990 @@ -2149,13 +2146,13 @@ static void rs_get_rate(void *priv_r, st
2991 }
2992
2993 if ((i < 0) || (i > IWL_RATE_COUNT)) {
2994 - sel->rate_idx = rate_lowest_index(sband, sta);
2995 + info->control.rates[0].idx = rate_lowest_index(sband, sta);
2996 return;
2997 }
2998
2999 if (sband->band == IEEE80211_BAND_5GHZ)
3000 i -= IWL_FIRST_OFDM_RATE;
3001 - sel->rate_idx = i;
3002 + info->control.rates[0].idx = i;
3003 }
3004
3005 static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
This page took 0.223076 seconds and 5 git commands to generate.