~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/net/wireless/wl12xx/tx.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <linux/kernel.h>
25
25
#include <linux/module.h>
 
26
#include <linux/etherdevice.h>
26
27
 
27
28
#include "wl12xx.h"
28
29
#include "io.h"
30
31
#include "ps.h"
31
32
#include "tx.h"
32
33
 
 
34
static int wl1271_set_default_wep_key(struct wl1271 *wl, u8 id)
 
35
{
 
36
        int ret;
 
37
        bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
 
38
 
 
39
        if (is_ap)
 
40
                ret = wl1271_cmd_set_ap_default_wep_key(wl, id);
 
41
        else
 
42
                ret = wl1271_cmd_set_sta_default_wep_key(wl, id);
 
43
 
 
44
        if (ret < 0)
 
45
                return ret;
 
46
 
 
47
        wl1271_debug(DEBUG_CRYPT, "default wep key idx: %d", (int)id);
 
48
        return 0;
 
49
}
 
50
 
33
51
static int wl1271_alloc_tx_id(struct wl1271 *wl, struct sk_buff *skb)
34
52
{
35
53
        int id;
52
70
        }
53
71
}
54
72
 
 
73
static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl,
 
74
                                                 struct sk_buff *skb)
 
75
{
 
76
        struct ieee80211_hdr *hdr;
 
77
 
 
78
        /*
 
79
         * add the station to the known list before transmitting the
 
80
         * authentication response. this way it won't get de-authed by FW
 
81
         * when transmitting too soon.
 
82
         */
 
83
        hdr = (struct ieee80211_hdr *)(skb->data +
 
84
                                       sizeof(struct wl1271_tx_hw_descr));
 
85
        if (ieee80211_is_auth(hdr->frame_control))
 
86
                wl1271_acx_set_inconnection_sta(wl, hdr->addr1);
 
87
}
 
88
 
 
89
static void wl1271_tx_regulate_link(struct wl1271 *wl, u8 hlid)
 
90
{
 
91
        bool fw_ps;
 
92
        u8 tx_blks;
 
93
 
 
94
        /* only regulate station links */
 
95
        if (hlid < WL1271_AP_STA_HLID_START)
 
96
                return;
 
97
 
 
98
        fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);
 
99
        tx_blks = wl->links[hlid].allocated_blks;
 
100
 
 
101
        /*
 
102
         * if in FW PS and there is enough data in FW we can put the link
 
103
         * into high-level PS and clean out its TX queues.
 
104
         */
 
105
        if (fw_ps && tx_blks >= WL1271_PS_STA_MAX_BLOCKS)
 
106
                wl1271_ps_link_start(wl, hlid, true);
 
107
}
 
108
 
 
109
u8 wl1271_tx_get_hlid(struct sk_buff *skb)
 
110
{
 
111
        struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb);
 
112
 
 
113
        if (control->control.sta) {
 
114
                struct wl1271_station *wl_sta;
 
115
 
 
116
                wl_sta = (struct wl1271_station *)
 
117
                                control->control.sta->drv_priv;
 
118
                return wl_sta->hlid;
 
119
        } else {
 
120
                struct ieee80211_hdr *hdr;
 
121
 
 
122
                hdr = (struct ieee80211_hdr *)skb->data;
 
123
                if (ieee80211_is_mgmt(hdr->frame_control))
 
124
                        return WL1271_AP_GLOBAL_HLID;
 
125
                else
 
126
                        return WL1271_AP_BROADCAST_HLID;
 
127
        }
 
128
}
 
129
 
55
130
static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
56
 
                                u32 buf_offset)
 
131
                                u32 buf_offset, u8 hlid)
57
132
{
58
133
        struct wl1271_tx_hw_descr *desc;
59
134
        u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra;
82
157
 
83
158
                wl->tx_blocks_available -= total_blocks;
84
159
 
 
160
                if (wl->bss_type == BSS_TYPE_AP_BSS)
 
161
                        wl->links[hlid].allocated_blks += total_blocks;
 
162
 
85
163
                ret = 0;
86
164
 
87
165
                wl1271_debug(DEBUG_TX,
95
173
}
96
174
 
97
175
static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
98
 
                              u32 extra, struct ieee80211_tx_info *control)
 
176
                              u32 extra, struct ieee80211_tx_info *control,
 
177
                              u8 hlid)
99
178
{
100
179
        struct timespec ts;
101
180
        struct wl1271_tx_hw_descr *desc;
102
 
        int pad, ac;
 
181
        int pad, ac, rate_idx;
103
182
        s64 hosttime;
104
183
        u16 tx_attr;
105
184
 
117
196
        getnstimeofday(&ts);
118
197
        hosttime = (timespec_to_ns(&ts) >> 10);
119
198
        desc->start_time = cpu_to_le32(hosttime - wl->time_offset);
120
 
        desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU);
 
199
 
 
200
        if (wl->bss_type != BSS_TYPE_AP_BSS)
 
201
                desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU);
 
202
        else
 
203
                desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU);
121
204
 
122
205
        /* configure the tx attributes */
123
206
        tx_attr = wl->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER;
125
208
        /* queue (we use same identifiers for tid's and ac's */
126
209
        ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
127
210
        desc->tid = ac;
128
 
        desc->aid = TX_HW_DEFAULT_AID;
 
211
 
 
212
        if (wl->bss_type != BSS_TYPE_AP_BSS) {
 
213
                desc->aid = hlid;
 
214
 
 
215
                /* if the packets are destined for AP (have a STA entry)
 
216
                   send them with AP rate policies, otherwise use default
 
217
                   basic rates */
 
218
                if (control->control.sta)
 
219
                        rate_idx = ACX_TX_AP_FULL_RATE;
 
220
                else
 
221
                        rate_idx = ACX_TX_BASIC_RATE;
 
222
        } else {
 
223
                desc->hlid = hlid;
 
224
                switch (hlid) {
 
225
                case WL1271_AP_GLOBAL_HLID:
 
226
                        rate_idx = ACX_TX_AP_MODE_MGMT_RATE;
 
227
                        break;
 
228
                case WL1271_AP_BROADCAST_HLID:
 
229
                        rate_idx = ACX_TX_AP_MODE_BCST_RATE;
 
230
                        break;
 
231
                default:
 
232
                        rate_idx = ac;
 
233
                        break;
 
234
                }
 
235
        }
 
236
 
 
237
        tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY;
129
238
        desc->reserved = 0;
130
239
 
131
240
        /* align the length (and store in terms of words) */
132
 
        pad = WL1271_TX_ALIGN(skb->len);
 
241
        pad = ALIGN(skb->len, WL1271_TX_ALIGN_TO);
133
242
        desc->length = cpu_to_le16(pad >> 2);
134
243
 
135
244
        /* calculate number of padding bytes */
136
245
        pad = pad - skb->len;
137
246
        tx_attr |= pad << TX_HW_ATTR_OFST_LAST_WORD_PAD;
138
247
 
139
 
        /* if the packets are destined for AP (have a STA entry) send them
140
 
           with AP rate policies, otherwise use default basic rates */
141
 
        if (control->control.sta)
142
 
                tx_attr |= ACX_TX_AP_FULL_RATE << TX_HW_ATTR_OFST_RATE_POLICY;
143
 
 
144
248
        desc->tx_attr = cpu_to_le16(tx_attr);
145
249
 
146
 
        wl1271_debug(DEBUG_TX, "tx_fill_hdr: pad: %d", pad);
 
250
        wl1271_debug(DEBUG_TX, "tx_fill_hdr: pad: %d hlid: %d "
 
251
                "tx_attr: 0x%x len: %d life: %d mem: %d", pad, desc->hlid,
 
252
                le16_to_cpu(desc->tx_attr), le16_to_cpu(desc->length),
 
253
                le16_to_cpu(desc->life_time), desc->total_mem_blocks);
147
254
}
148
255
 
149
256
/* caller must hold wl->mutex */
153
260
        struct ieee80211_tx_info *info;
154
261
        u32 extra = 0;
155
262
        int ret = 0;
156
 
        u8 idx;
157
263
        u32 total_len;
 
264
        u8 hlid;
158
265
 
159
266
        if (!skb)
160
267
                return -EINVAL;
166
273
                extra = WL1271_TKIP_IV_SPACE;
167
274
 
168
275
        if (info->control.hw_key) {
169
 
                idx = info->control.hw_key->hw_key_idx;
170
 
 
171
 
                /* FIXME: do we have to do this if we're not using WEP? */
172
 
                if (unlikely(wl->default_key != idx)) {
173
 
                        ret = wl1271_cmd_set_default_wep_key(wl, idx);
 
276
                bool is_wep;
 
277
                u8 idx = info->control.hw_key->hw_key_idx;
 
278
                u32 cipher = info->control.hw_key->cipher;
 
279
 
 
280
                is_wep = (cipher == WLAN_CIPHER_SUITE_WEP40) ||
 
281
                         (cipher == WLAN_CIPHER_SUITE_WEP104);
 
282
 
 
283
                if (unlikely(is_wep && wl->default_key != idx)) {
 
284
                        ret = wl1271_set_default_wep_key(wl, idx);
174
285
                        if (ret < 0)
175
286
                                return ret;
176
287
                        wl->default_key = idx;
177
288
                }
178
289
        }
179
290
 
180
 
        ret = wl1271_tx_allocate(wl, skb, extra, buf_offset);
 
291
        if (wl->bss_type == BSS_TYPE_AP_BSS)
 
292
                hlid = wl1271_tx_get_hlid(skb);
 
293
        else
 
294
                hlid = TX_HW_DEFAULT_AID;
 
295
 
 
296
        ret = wl1271_tx_allocate(wl, skb, extra, buf_offset, hlid);
181
297
        if (ret < 0)
182
298
                return ret;
183
299
 
184
 
        wl1271_tx_fill_hdr(wl, skb, extra, info);
 
300
        if (wl->bss_type == BSS_TYPE_AP_BSS) {
 
301
                wl1271_tx_ap_update_inconnection_sta(wl, skb);
 
302
                wl1271_tx_regulate_link(wl, hlid);
 
303
        }
 
304
 
 
305
        wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);
185
306
 
186
307
        /*
187
308
         * The length of each packet is stored in terms of words. Thus, we must
188
309
         * pad the skb data to make sure its length is aligned.
189
310
         * The number of padding bytes is computed and set in wl1271_tx_fill_hdr
190
311
         */
191
 
        total_len = WL1271_TX_ALIGN(skb->len);
 
312
        total_len = ALIGN(skb->len, WL1271_TX_ALIGN_TO);
192
313
        memcpy(wl->aggr_buf + buf_offset, skb->data, skb->len);
193
314
        memset(wl->aggr_buf + buf_offset + skb->len, 0, total_len - skb->len);
194
315
 
222
343
        return enabled_rates;
223
344
}
224
345
 
225
 
static void handle_tx_low_watermark(struct wl1271 *wl)
 
346
void wl1271_handle_tx_low_watermark(struct wl1271 *wl)
226
347
{
227
348
        unsigned long flags;
228
349
 
236
357
        }
237
358
}
238
359
 
239
 
static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
 
360
static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl)
240
361
{
241
362
        struct sk_buff *skb = NULL;
242
363
        unsigned long flags;
262
383
        return skb;
263
384
}
264
385
 
 
386
static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl)
 
387
{
 
388
        struct sk_buff *skb = NULL;
 
389
        unsigned long flags;
 
390
        int i, h, start_hlid;
 
391
 
 
392
        /* start from the link after the last one */
 
393
        start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS;
 
394
 
 
395
        /* dequeue according to AC, round robin on each link */
 
396
        for (i = 0; i < AP_MAX_LINKS; i++) {
 
397
                h = (start_hlid + i) % AP_MAX_LINKS;
 
398
 
 
399
                skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VO]);
 
400
                if (skb)
 
401
                        goto out;
 
402
                skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VI]);
 
403
                if (skb)
 
404
                        goto out;
 
405
                skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BE]);
 
406
                if (skb)
 
407
                        goto out;
 
408
                skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BK]);
 
409
                if (skb)
 
410
                        goto out;
 
411
        }
 
412
 
 
413
out:
 
414
        if (skb) {
 
415
                wl->last_tx_hlid = h;
 
416
                spin_lock_irqsave(&wl->wl_lock, flags);
 
417
                wl->tx_queue_count--;
 
418
                spin_unlock_irqrestore(&wl->wl_lock, flags);
 
419
        } else {
 
420
                wl->last_tx_hlid = 0;
 
421
        }
 
422
 
 
423
        return skb;
 
424
}
 
425
 
 
426
static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
 
427
{
 
428
        if (wl->bss_type == BSS_TYPE_AP_BSS)
 
429
                return wl1271_ap_skb_dequeue(wl);
 
430
 
 
431
        return wl1271_sta_skb_dequeue(wl);
 
432
}
 
433
 
265
434
static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb)
266
435
{
267
436
        unsigned long flags;
268
437
        int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
269
438
 
270
 
        skb_queue_head(&wl->tx_queue[q], skb);
 
439
        if (wl->bss_type == BSS_TYPE_AP_BSS) {
 
440
                u8 hlid = wl1271_tx_get_hlid(skb);
 
441
                skb_queue_head(&wl->links[hlid].tx_queue[q], skb);
 
442
 
 
443
                /* make sure we dequeue the same packet next time */
 
444
                wl->last_tx_hlid = (hlid + AP_MAX_LINKS - 1) % AP_MAX_LINKS;
 
445
        } else {
 
446
                skb_queue_head(&wl->tx_queue[q], skb);
 
447
        }
 
448
 
271
449
        spin_lock_irqsave(&wl->wl_lock, flags);
272
450
        wl->tx_queue_count++;
273
451
        spin_unlock_irqrestore(&wl->wl_lock, flags);
277
455
{
278
456
        struct sk_buff *skb;
279
457
        bool woken_up = false;
280
 
        u32 sta_rates = 0;
281
458
        u32 buf_offset = 0;
282
459
        bool sent_packets = false;
283
460
        int ret;
284
461
 
285
 
        /* check if the rates supported by the AP have changed */
286
 
        if (unlikely(test_and_clear_bit(WL1271_FLAG_STA_RATES_CHANGED,
287
 
                                        &wl->flags))) {
288
 
                unsigned long flags;
289
 
 
290
 
                spin_lock_irqsave(&wl->wl_lock, flags);
291
 
                sta_rates = wl->sta_rate_set;
292
 
                spin_unlock_irqrestore(&wl->wl_lock, flags);
293
 
        }
294
 
 
295
462
        if (unlikely(wl->state == WL1271_STATE_OFF))
296
463
                goto out;
297
464
 
298
 
        /* if rates have changed, re-configure the rate policy */
299
 
        if (unlikely(sta_rates)) {
300
 
                ret = wl1271_ps_elp_wakeup(wl, false);
301
 
                if (ret < 0)
302
 
                        goto out;
303
 
                woken_up = true;
304
 
 
305
 
                wl->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rates);
306
 
                wl1271_acx_rate_policies(wl);
307
 
        }
308
 
 
309
465
        while ((skb = wl1271_skb_dequeue(wl))) {
310
466
                if (!woken_up) {
311
 
                        ret = wl1271_ps_elp_wakeup(wl, false);
 
467
                        ret = wl1271_ps_elp_wakeup(wl);
312
468
                        if (ret < 0)
313
469
                                goto out_ack;
314
470
                        woken_up = true;
350
506
                sent_packets = true;
351
507
        }
352
508
        if (sent_packets) {
353
 
                /* interrupt the firmware with the new packets */
354
 
                wl1271_write32(wl, WL1271_HOST_WR_ACCESS, wl->tx_packets_count);
355
 
                handle_tx_low_watermark(wl);
 
509
                /*
 
510
                 * Interrupt the firmware with the new packets. This is only
 
511
                 * required for older hardware revisions
 
512
                 */
 
513
                if (wl->quirks & WL12XX_QUIRK_END_OF_TRANSACTION)
 
514
                        wl1271_write32(wl, WL1271_HOST_WR_ACCESS,
 
515
                                       wl->tx_packets_count);
 
516
 
 
517
                wl1271_handle_tx_low_watermark(wl);
356
518
        }
357
519
 
358
520
out:
427
589
                     result->rate_class_index, result->status);
428
590
 
429
591
        /* return the packet to the stack */
430
 
        ieee80211_tx_status(wl->hw, skb);
 
592
        skb_queue_tail(&wl->deferred_tx_queue, skb);
 
593
        ieee80211_queue_work(wl->hw, &wl->netstack_work);
431
594
        wl1271_free_tx_id(wl, result->id);
432
595
}
433
596
 
469
632
        }
470
633
}
471
634
 
 
635
void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)
 
636
{
 
637
        struct sk_buff *skb;
 
638
        int i, total = 0;
 
639
        unsigned long flags;
 
640
        struct ieee80211_tx_info *info;
 
641
 
 
642
        for (i = 0; i < NUM_TX_QUEUES; i++) {
 
643
                while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) {
 
644
                        wl1271_debug(DEBUG_TX, "link freeing skb 0x%p", skb);
 
645
                        info = IEEE80211_SKB_CB(skb);
 
646
                        info->status.rates[0].idx = -1;
 
647
                        info->status.rates[0].count = 0;
 
648
                        ieee80211_tx_status(wl->hw, skb);
 
649
                        total++;
 
650
                }
 
651
        }
 
652
 
 
653
        spin_lock_irqsave(&wl->wl_lock, flags);
 
654
        wl->tx_queue_count -= total;
 
655
        spin_unlock_irqrestore(&wl->wl_lock, flags);
 
656
 
 
657
        wl1271_handle_tx_low_watermark(wl);
 
658
}
 
659
 
472
660
/* caller must hold wl->mutex */
473
661
void wl1271_tx_reset(struct wl1271 *wl)
474
662
{
475
663
        int i;
476
664
        struct sk_buff *skb;
 
665
        struct ieee80211_tx_info *info;
477
666
 
478
667
        /* TX failure */
479
 
        for (i = 0; i < NUM_TX_QUEUES; i++) {
480
 
                while ((skb = skb_dequeue(&wl->tx_queue[i]))) {
481
 
                        wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);
482
 
                        ieee80211_tx_status(wl->hw, skb);
 
668
        if (wl->bss_type == BSS_TYPE_AP_BSS) {
 
669
                for (i = 0; i < AP_MAX_LINKS; i++) {
 
670
                        wl1271_tx_reset_link_queues(wl, i);
 
671
                        wl->links[i].allocated_blks = 0;
 
672
                        wl->links[i].prev_freed_blks = 0;
 
673
                }
 
674
 
 
675
                wl->last_tx_hlid = 0;
 
676
        } else {
 
677
                for (i = 0; i < NUM_TX_QUEUES; i++) {
 
678
                        while ((skb = skb_dequeue(&wl->tx_queue[i]))) {
 
679
                                wl1271_debug(DEBUG_TX, "freeing skb 0x%p",
 
680
                                             skb);
 
681
                                info = IEEE80211_SKB_CB(skb);
 
682
                                info->status.rates[0].idx = -1;
 
683
                                info->status.rates[0].count = 0;
 
684
                                ieee80211_tx_status(wl->hw, skb);
 
685
                        }
483
686
                }
484
687
        }
 
688
 
485
689
        wl->tx_queue_count = 0;
486
690
 
487
691
        /*
488
692
         * Make sure the driver is at a consistent state, in case this
489
693
         * function is called from a context other than interface removal.
490
694
         */
491
 
        handle_tx_low_watermark(wl);
492
 
 
493
 
        for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
494
 
                if (wl->tx_frames[i] != NULL) {
495
 
                        skb = wl->tx_frames[i];
496
 
                        wl1271_free_tx_id(wl, i);
497
 
                        wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);
498
 
                        ieee80211_tx_status(wl->hw, skb);
 
695
        wl1271_handle_tx_low_watermark(wl);
 
696
 
 
697
        for (i = 0; i < ACX_TX_DESCRIPTORS; i++) {
 
698
                if (wl->tx_frames[i] == NULL)
 
699
                        continue;
 
700
 
 
701
                skb = wl->tx_frames[i];
 
702
                wl1271_free_tx_id(wl, i);
 
703
                wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);
 
704
 
 
705
                /* Remove private headers before passing the skb to mac80211 */
 
706
                info = IEEE80211_SKB_CB(skb);
 
707
                skb_pull(skb, sizeof(struct wl1271_tx_hw_descr));
 
708
                if (info->control.hw_key &&
 
709
                    info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
 
710
                        int hdrlen = ieee80211_get_hdrlen_from_skb(skb);
 
711
                        memmove(skb->data + WL1271_TKIP_IV_SPACE, skb->data,
 
712
                                hdrlen);
 
713
                        skb_pull(skb, WL1271_TKIP_IV_SPACE);
499
714
                }
 
715
 
 
716
                info->status.rates[0].idx = -1;
 
717
                info->status.rates[0].count = 0;
 
718
 
 
719
                ieee80211_tx_status(wl->hw, skb);
 
720
        }
500
721
}
501
722
 
502
723
#define WL1271_TX_FLUSH_TIMEOUT 500000
509
730
 
510
731
        while (!time_after(jiffies, timeout)) {
511
732
                mutex_lock(&wl->mutex);
512
 
                wl1271_debug(DEBUG_TX, "flushing tx buffer: %d",
513
 
                             wl->tx_frames_cnt);
 
733
                wl1271_debug(DEBUG_TX, "flushing tx buffer: %d %d",
 
734
                             wl->tx_frames_cnt, wl->tx_queue_count);
514
735
                if ((wl->tx_frames_cnt == 0) && (wl->tx_queue_count == 0)) {
515
736
                        mutex_unlock(&wl->mutex);
516
737
                        return;
521
742
 
522
743
        wl1271_warning("Unable to flush all TX buffers, timed out.");
523
744
}
 
745
 
 
746
u32 wl1271_tx_min_rate_get(struct wl1271 *wl)
 
747
{
 
748
        int i;
 
749
        u32 rate = 0;
 
750
 
 
751
        if (!wl->basic_rate_set) {
 
752
                WARN_ON(1);
 
753
                wl->basic_rate_set = wl->conf.tx.basic_rate;
 
754
        }
 
755
 
 
756
        for (i = 0; !rate; i++) {
 
757
                if ((wl->basic_rate_set >> i) & 0x1)
 
758
                        rate = 1 << i;
 
759
        }
 
760
 
 
761
        return rate;
 
762
}