73
static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl,
76
struct ieee80211_hdr *hdr;
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.
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);
89
static void wl1271_tx_regulate_link(struct wl1271 *wl, u8 hlid)
94
/* only regulate station links */
95
if (hlid < WL1271_AP_STA_HLID_START)
98
fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);
99
tx_blks = wl->links[hlid].allocated_blks;
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.
105
if (fw_ps && tx_blks >= WL1271_PS_STA_MAX_BLOCKS)
106
wl1271_ps_link_start(wl, hlid, true);
109
u8 wl1271_tx_get_hlid(struct sk_buff *skb)
111
struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb);
113
if (control->control.sta) {
114
struct wl1271_station *wl_sta;
116
wl_sta = (struct wl1271_station *)
117
control->control.sta->drv_priv;
120
struct ieee80211_hdr *hdr;
122
hdr = (struct ieee80211_hdr *)skb->data;
123
if (ieee80211_is_mgmt(hdr->frame_control))
124
return WL1271_AP_GLOBAL_HLID;
126
return WL1271_AP_BROADCAST_HLID;
55
130
static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
131
u32 buf_offset, u8 hlid)
58
133
struct wl1271_tx_hw_descr *desc;
59
134
u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra;
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));
128
desc->aid = TX_HW_DEFAULT_AID;
212
if (wl->bss_type != BSS_TYPE_AP_BSS) {
215
/* if the packets are destined for AP (have a STA entry)
216
send them with AP rate policies, otherwise use default
218
if (control->control.sta)
219
rate_idx = ACX_TX_AP_FULL_RATE;
221
rate_idx = ACX_TX_BASIC_RATE;
225
case WL1271_AP_GLOBAL_HLID:
226
rate_idx = ACX_TX_AP_MODE_MGMT_RATE;
228
case WL1271_AP_BROADCAST_HLID:
229
rate_idx = ACX_TX_AP_MODE_BCST_RATE;
237
tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY;
129
238
desc->reserved = 0;
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);
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;
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;
144
248
desc->tx_attr = cpu_to_le16(tx_attr);
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);
149
256
/* caller must hold wl->mutex */
166
273
extra = WL1271_TKIP_IV_SPACE;
168
275
if (info->control.hw_key) {
169
idx = info->control.hw_key->hw_key_idx;
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);
277
u8 idx = info->control.hw_key->hw_key_idx;
278
u32 cipher = info->control.hw_key->cipher;
280
is_wep = (cipher == WLAN_CIPHER_SUITE_WEP40) ||
281
(cipher == WLAN_CIPHER_SUITE_WEP104);
283
if (unlikely(is_wep && wl->default_key != idx)) {
284
ret = wl1271_set_default_wep_key(wl, idx);
176
287
wl->default_key = idx;
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);
294
hlid = TX_HW_DEFAULT_AID;
296
ret = wl1271_tx_allocate(wl, skb, extra, buf_offset, hlid);
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);
305
wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);
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
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);
386
static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl)
388
struct sk_buff *skb = NULL;
390
int i, h, start_hlid;
392
/* start from the link after the last one */
393
start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS;
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;
399
skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VO]);
402
skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VI]);
405
skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BE]);
408
skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BK]);
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);
420
wl->last_tx_hlid = 0;
426
static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
428
if (wl->bss_type == BSS_TYPE_AP_BSS)
429
return wl1271_ap_skb_dequeue(wl);
431
return wl1271_sta_skb_dequeue(wl);
265
434
static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb)
267
436
unsigned long flags;
268
437
int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
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);
443
/* make sure we dequeue the same packet next time */
444
wl->last_tx_hlid = (hlid + AP_MAX_LINKS - 1) % AP_MAX_LINKS;
446
skb_queue_head(&wl->tx_queue[q], skb);
271
449
spin_lock_irqsave(&wl->wl_lock, flags);
272
450
wl->tx_queue_count++;
273
451
spin_unlock_irqrestore(&wl->wl_lock, flags);
278
456
struct sk_buff *skb;
279
457
bool woken_up = false;
281
458
u32 buf_offset = 0;
282
459
bool sent_packets = false;
285
/* check if the rates supported by the AP have changed */
286
if (unlikely(test_and_clear_bit(WL1271_FLAG_STA_RATES_CHANGED,
290
spin_lock_irqsave(&wl->wl_lock, flags);
291
sta_rates = wl->sta_rate_set;
292
spin_unlock_irqrestore(&wl->wl_lock, flags);
295
462
if (unlikely(wl->state == WL1271_STATE_OFF))
298
/* if rates have changed, re-configure the rate policy */
299
if (unlikely(sta_rates)) {
300
ret = wl1271_ps_elp_wakeup(wl, false);
305
wl->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rates);
306
wl1271_acx_rate_policies(wl);
309
465
while ((skb = wl1271_skb_dequeue(wl))) {
311
ret = wl1271_ps_elp_wakeup(wl, false);
467
ret = wl1271_ps_elp_wakeup(wl);
635
void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)
640
struct ieee80211_tx_info *info;
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);
653
spin_lock_irqsave(&wl->wl_lock, flags);
654
wl->tx_queue_count -= total;
655
spin_unlock_irqrestore(&wl->wl_lock, flags);
657
wl1271_handle_tx_low_watermark(wl);
472
660
/* caller must hold wl->mutex */
473
661
void wl1271_tx_reset(struct wl1271 *wl)
476
664
struct sk_buff *skb;
665
struct ieee80211_tx_info *info;
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;
675
wl->last_tx_hlid = 0;
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",
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);
485
689
wl->tx_queue_count = 0;
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.
491
handle_tx_low_watermark(wl);
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);
697
for (i = 0; i < ACX_TX_DESCRIPTORS; i++) {
698
if (wl->tx_frames[i] == NULL)
701
skb = wl->tx_frames[i];
702
wl1271_free_tx_id(wl, i);
703
wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);
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,
713
skb_pull(skb, WL1271_TKIP_IV_SPACE);
716
info->status.rates[0].idx = -1;
717
info->status.rates[0].count = 0;
719
ieee80211_tx_status(wl->hw, skb);
502
723
#define WL1271_TX_FLUSH_TIMEOUT 500000