b43: Fix radio ID register reading
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / wireless / b43 / xmit.c
CommitLineData
e4d6b795
MB
1/*
2
3 Broadcom B43 wireless driver
4
5 Transmission (TX/RX) related functions.
6
7 Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
1f21ad2a 8 Copyright (C) 2005 Stefano Brivio <stefano.brivio@polimi.it>
e4d6b795
MB
9 Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de>
10 Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
11 Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; see the file COPYING. If not, write to
25 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
26 Boston, MA 02110-1301, USA.
27
28*/
29
30#include "xmit.h"
31#include "phy.h"
32#include "dma.h"
03b29773 33
e4d6b795
MB
34
35/* Extract the bitrate out of a CCK PLCP header. */
36static u8 b43_plcp_get_bitrate_cck(struct b43_plcp_hdr6 *plcp)
37{
38 switch (plcp->raw[0]) {
39 case 0x0A:
40 return B43_CCK_RATE_1MB;
41 case 0x14:
42 return B43_CCK_RATE_2MB;
43 case 0x37:
44 return B43_CCK_RATE_5MB;
45 case 0x6E:
46 return B43_CCK_RATE_11MB;
47 }
48 B43_WARN_ON(1);
49 return 0;
50}
51
52/* Extract the bitrate out of an OFDM PLCP header. */
53static u8 b43_plcp_get_bitrate_ofdm(struct b43_plcp_hdr6 *plcp)
54{
55 switch (plcp->raw[0] & 0xF) {
56 case 0xB:
57 return B43_OFDM_RATE_6MB;
58 case 0xF:
59 return B43_OFDM_RATE_9MB;
60 case 0xA:
61 return B43_OFDM_RATE_12MB;
62 case 0xE:
63 return B43_OFDM_RATE_18MB;
64 case 0x9:
65 return B43_OFDM_RATE_24MB;
66 case 0xD:
67 return B43_OFDM_RATE_36MB;
68 case 0x8:
69 return B43_OFDM_RATE_48MB;
70 case 0xC:
71 return B43_OFDM_RATE_54MB;
72 }
73 B43_WARN_ON(1);
74 return 0;
75}
76
77u8 b43_plcp_get_ratecode_cck(const u8 bitrate)
78{
79 switch (bitrate) {
80 case B43_CCK_RATE_1MB:
81 return 0x0A;
82 case B43_CCK_RATE_2MB:
83 return 0x14;
84 case B43_CCK_RATE_5MB:
85 return 0x37;
86 case B43_CCK_RATE_11MB:
87 return 0x6E;
88 }
89 B43_WARN_ON(1);
90 return 0;
91}
92
93u8 b43_plcp_get_ratecode_ofdm(const u8 bitrate)
94{
95 switch (bitrate) {
96 case B43_OFDM_RATE_6MB:
97 return 0xB;
98 case B43_OFDM_RATE_9MB:
99 return 0xF;
100 case B43_OFDM_RATE_12MB:
101 return 0xA;
102 case B43_OFDM_RATE_18MB:
103 return 0xE;
104 case B43_OFDM_RATE_24MB:
105 return 0x9;
106 case B43_OFDM_RATE_36MB:
107 return 0xD;
108 case B43_OFDM_RATE_48MB:
109 return 0x8;
110 case B43_OFDM_RATE_54MB:
111 return 0xC;
112 }
113 B43_WARN_ON(1);
114 return 0;
115}
116
117void b43_generate_plcp_hdr(struct b43_plcp_hdr4 *plcp,
118 const u16 octets, const u8 bitrate)
119{
120 __le32 *data = &(plcp->data);
121 __u8 *raw = plcp->raw;
122
123 if (b43_is_ofdm_rate(bitrate)) {
1a09404a
MB
124 u32 d;
125
126 d = b43_plcp_get_ratecode_ofdm(bitrate);
e4d6b795 127 B43_WARN_ON(octets & 0xF000);
1a09404a
MB
128 d |= (octets << 5);
129 *data = cpu_to_le32(d);
e4d6b795
MB
130 } else {
131 u32 plen;
132
133 plen = octets * 16 / bitrate;
134 if ((octets * 16 % bitrate) > 0) {
135 plen++;
136 if ((bitrate == B43_CCK_RATE_11MB)
137 && ((octets * 8 % 11) < 4)) {
138 raw[1] = 0x84;
139 } else
140 raw[1] = 0x04;
141 } else
142 raw[1] = 0x04;
143 *data |= cpu_to_le32(plen << 16);
144 raw[0] = b43_plcp_get_ratecode_cck(bitrate);
145 }
146}
147
148static u8 b43_calc_fallback_rate(u8 bitrate)
149{
150 switch (bitrate) {
151 case B43_CCK_RATE_1MB:
152 return B43_CCK_RATE_1MB;
153 case B43_CCK_RATE_2MB:
154 return B43_CCK_RATE_1MB;
155 case B43_CCK_RATE_5MB:
156 return B43_CCK_RATE_2MB;
157 case B43_CCK_RATE_11MB:
158 return B43_CCK_RATE_5MB;
159 case B43_OFDM_RATE_6MB:
160 return B43_CCK_RATE_5MB;
161 case B43_OFDM_RATE_9MB:
162 return B43_OFDM_RATE_6MB;
163 case B43_OFDM_RATE_12MB:
164 return B43_OFDM_RATE_9MB;
165 case B43_OFDM_RATE_18MB:
166 return B43_OFDM_RATE_12MB;
167 case B43_OFDM_RATE_24MB:
168 return B43_OFDM_RATE_18MB;
169 case B43_OFDM_RATE_36MB:
170 return B43_OFDM_RATE_24MB;
171 case B43_OFDM_RATE_48MB:
172 return B43_OFDM_RATE_36MB;
173 case B43_OFDM_RATE_54MB:
174 return B43_OFDM_RATE_48MB;
175 }
176 B43_WARN_ON(1);
177 return 0;
178}
179
180static void generate_txhdr_fw4(struct b43_wldev *dev,
181 struct b43_txhdr_fw4 *txhdr,
182 const unsigned char *fragment_data,
183 unsigned int fragment_len,
184 const struct ieee80211_tx_control *txctl,
185 u16 cookie)
186{
187 const struct b43_phy *phy = &dev->phy;
188 const struct ieee80211_hdr *wlhdr =
189 (const struct ieee80211_hdr *)fragment_data;
190 int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT));
191 u16 fctl = le16_to_cpu(wlhdr->frame_control);
192 u8 rate, rate_fb;
193 int rate_ofdm, rate_fb_ofdm;
194 unsigned int plcp_fragment_len;
195 u32 mac_ctl = 0;
196 u16 phy_ctl = 0;
197 u8 extra_ft = 0;
198
199 memset(txhdr, 0, sizeof(*txhdr));
200
201 rate = txctl->tx_rate;
202 rate_ofdm = b43_is_ofdm_rate(rate);
203 rate_fb = (txctl->alt_retry_rate == -1) ? rate : txctl->alt_retry_rate;
204 rate_fb_ofdm = b43_is_ofdm_rate(rate_fb);
205
206 if (rate_ofdm)
207 txhdr->phy_rate = b43_plcp_get_ratecode_ofdm(rate);
208 else
209 txhdr->phy_rate = b43_plcp_get_ratecode_cck(rate);
210 txhdr->mac_frame_ctl = wlhdr->frame_control;
211 memcpy(txhdr->tx_receiver, wlhdr->addr1, 6);
212
213 /* Calculate duration for fallback rate */
214 if ((rate_fb == rate) ||
215 (wlhdr->duration_id & cpu_to_le16(0x8000)) ||
216 (wlhdr->duration_id == cpu_to_le16(0))) {
217 /* If the fallback rate equals the normal rate or the
218 * dur_id field contains an AID, CFP magic or 0,
219 * use the original dur_id field. */
220 txhdr->dur_fb = wlhdr->duration_id;
221 } else {
222 int fbrate_base100kbps = B43_RATE_TO_BASE100KBPS(rate_fb);
223 txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw,
32bfd35d 224 txctl->vif,
e4d6b795
MB
225 fragment_len,
226 fbrate_base100kbps);
227 }
228
229 plcp_fragment_len = fragment_len + FCS_LEN;
230 if (use_encryption) {
231 u8 key_idx = (u16) (txctl->key_idx);
232 struct b43_key *key;
233 int wlhdr_len;
234 size_t iv_len;
235
236 B43_WARN_ON(key_idx >= dev->max_nr_keys);
237 key = &(dev->key[key_idx]);
238 B43_WARN_ON(!key->keyconf);
239
240 /* Hardware appends ICV. */
241 plcp_fragment_len += txctl->icv_len;
242
243 key_idx = b43_kidx_to_fw(dev, key_idx);
244 mac_ctl |= (key_idx << B43_TX4_MAC_KEYIDX_SHIFT) &
245 B43_TX4_MAC_KEYIDX;
246 mac_ctl |= (key->algorithm << B43_TX4_MAC_KEYALG_SHIFT) &
247 B43_TX4_MAC_KEYALG;
248 wlhdr_len = ieee80211_get_hdrlen(fctl);
249 iv_len = min((size_t) txctl->iv_len,
250 ARRAY_SIZE(txhdr->iv));
251 memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len);
252 }
253 b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->plcp),
254 plcp_fragment_len, rate);
255 b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->plcp_fb),
256 plcp_fragment_len, rate_fb);
257
258 /* Extra Frame Types */
259 if (rate_fb_ofdm)
260 extra_ft |= B43_TX4_EFT_FBOFDM;
261
262 /* Set channel radio code. Note that the micrcode ORs 0x100 to
263 * this value before comparing it to the value in SHM, if this
264 * is a 5Ghz packet.
265 */
266 txhdr->chan_radio_code = phy->channel;
267
268 /* PHY TX Control word */
269 if (rate_ofdm)
270 phy_ctl |= B43_TX4_PHY_OFDM;
271 if (dev->short_preamble)
272 phy_ctl |= B43_TX4_PHY_SHORTPRMBL;
9db1f6d7
MB
273
274 switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) {
275 case 0: /* Default */
e4d6b795
MB
276 phy_ctl |= B43_TX4_PHY_ANTLAST;
277 break;
9db1f6d7 278 case 1: /* Antenna 0 */
e4d6b795
MB
279 phy_ctl |= B43_TX4_PHY_ANT0;
280 break;
9db1f6d7 281 case 2: /* Antenna 1 */
e4d6b795
MB
282 phy_ctl |= B43_TX4_PHY_ANT1;
283 break;
284 default:
285 B43_WARN_ON(1);
286 }
287
288 /* MAC control */
289 if (!(txctl->flags & IEEE80211_TXCTL_NO_ACK))
290 mac_ctl |= B43_TX4_MAC_ACK;
291 if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
292 ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)))
293 mac_ctl |= B43_TX4_MAC_HWSEQ;
294 if (txctl->flags & IEEE80211_TXCTL_FIRST_FRAGMENT)
295 mac_ctl |= B43_TX4_MAC_STMSDU;
296 if (phy->type == B43_PHYTYPE_A)
297 mac_ctl |= B43_TX4_MAC_5GHZ;
74cfdba7
MB
298 if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT)
299 mac_ctl |= B43_TX4_MAC_LONGFRAME;
e4d6b795
MB
300
301 /* Generate the RTS or CTS-to-self frame */
302 if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
303 (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) {
304 unsigned int len;
305 struct ieee80211_hdr *hdr;
306 int rts_rate, rts_rate_fb;
307 int rts_rate_ofdm, rts_rate_fb_ofdm;
308
309 rts_rate = txctl->rts_cts_rate;
310 rts_rate_ofdm = b43_is_ofdm_rate(rts_rate);
311 rts_rate_fb = b43_calc_fallback_rate(rts_rate);
312 rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb);
313
314 if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) {
32bfd35d 315 ieee80211_ctstoself_get(dev->wl->hw, txctl->vif,
e4d6b795
MB
316 fragment_data, fragment_len,
317 txctl,
318 (struct ieee80211_cts *)(txhdr->
319 rts_frame));
320 mac_ctl |= B43_TX4_MAC_SENDCTS;
321 len = sizeof(struct ieee80211_cts);
322 } else {
32bfd35d 323 ieee80211_rts_get(dev->wl->hw, txctl->vif,
e4d6b795
MB
324 fragment_data, fragment_len, txctl,
325 (struct ieee80211_rts *)(txhdr->
326 rts_frame));
327 mac_ctl |= B43_TX4_MAC_SENDRTS;
328 len = sizeof(struct ieee80211_rts);
329 }
330 len += FCS_LEN;
331 b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->
332 rts_plcp), len,
333 rts_rate);
334 b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->
335 rts_plcp_fb),
336 len, rts_rate_fb);
337 hdr = (struct ieee80211_hdr *)(&txhdr->rts_frame);
338 txhdr->rts_dur_fb = hdr->duration_id;
339 if (rts_rate_ofdm) {
340 extra_ft |= B43_TX4_EFT_RTSOFDM;
341 txhdr->phy_rate_rts =
342 b43_plcp_get_ratecode_ofdm(rts_rate);
343 } else
344 txhdr->phy_rate_rts =
345 b43_plcp_get_ratecode_cck(rts_rate);
346 if (rts_rate_fb_ofdm)
347 extra_ft |= B43_TX4_EFT_RTSFBOFDM;
e4d6b795
MB
348 }
349
350 /* Magic cookie */
351 txhdr->cookie = cpu_to_le16(cookie);
352
353 /* Apply the bitfields */
354 txhdr->mac_ctl = cpu_to_le32(mac_ctl);
355 txhdr->phy_ctl = cpu_to_le16(phy_ctl);
356 txhdr->extra_ft = extra_ft;
357}
358
359void b43_generate_txhdr(struct b43_wldev *dev,
360 u8 * txhdr,
361 const unsigned char *fragment_data,
362 unsigned int fragment_len,
363 const struct ieee80211_tx_control *txctl, u16 cookie)
364{
365 generate_txhdr_fw4(dev, (struct b43_txhdr_fw4 *)txhdr,
366 fragment_data, fragment_len, txctl, cookie);
367}
368
369static s8 b43_rssi_postprocess(struct b43_wldev *dev,
370 u8 in_rssi, int ofdm,
371 int adjust_2053, int adjust_2050)
372{
373 struct b43_phy *phy = &dev->phy;
374 s32 tmp;
375
376 switch (phy->radio_ver) {
377 case 0x2050:
378 if (ofdm) {
379 tmp = in_rssi;
380 if (tmp > 127)
381 tmp -= 256;
382 tmp *= 73;
383 tmp /= 64;
384 if (adjust_2050)
385 tmp += 25;
386 else
387 tmp -= 3;
388 } else {
95de2841 389 if (dev->dev->bus->sprom.
e4d6b795
MB
390 boardflags_lo & B43_BFL_RSSI) {
391 if (in_rssi > 63)
392 in_rssi = 63;
393 tmp = phy->nrssi_lt[in_rssi];
394 tmp = 31 - tmp;
395 tmp *= -131;
396 tmp /= 128;
397 tmp -= 57;
398 } else {
399 tmp = in_rssi;
400 tmp = 31 - tmp;
401 tmp *= -149;
402 tmp /= 128;
403 tmp -= 68;
404 }
405 if (phy->type == B43_PHYTYPE_G && adjust_2050)
406 tmp += 25;
407 }
408 break;
409 case 0x2060:
410 if (in_rssi > 127)
411 tmp = in_rssi - 256;
412 else
413 tmp = in_rssi;
414 break;
415 default:
416 tmp = in_rssi;
417 tmp -= 11;
418 tmp *= 103;
419 tmp /= 64;
420 if (adjust_2053)
421 tmp -= 109;
422 else
423 tmp -= 83;
424 }
425
426 return (s8) tmp;
427}
428
429//TODO
430#if 0
431static s8 b43_rssinoise_postprocess(struct b43_wldev *dev, u8 in_rssi)
432{
433 struct b43_phy *phy = &dev->phy;
434 s8 ret;
435
436 if (phy->type == B43_PHYTYPE_A) {
437 //TODO: Incomplete specs.
438 ret = 0;
439 } else
440 ret = b43_rssi_postprocess(dev, in_rssi, 0, 1, 1);
441
442 return ret;
443}
444#endif
445
446void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
447{
448 struct ieee80211_rx_status status;
449 struct b43_plcp_hdr6 *plcp;
450 struct ieee80211_hdr *wlhdr;
451 const struct b43_rxhdr_fw4 *rxhdr = _rxhdr;
452 u16 fctl;
453 u16 phystat0, phystat3, chanstat, mactime;
454 u32 macstat;
455 u16 chanid;
456 u8 jssi;
457 int padding;
458
459 memset(&status, 0, sizeof(status));
460
461 /* Get metadata about the frame from the header. */
462 phystat0 = le16_to_cpu(rxhdr->phy_status0);
463 phystat3 = le16_to_cpu(rxhdr->phy_status3);
464 jssi = rxhdr->jssi;
465 macstat = le32_to_cpu(rxhdr->mac_status);
466 mactime = le16_to_cpu(rxhdr->mac_time);
467 chanstat = le16_to_cpu(rxhdr->channel);
468
469 if (macstat & B43_RX_MAC_FCSERR)
470 dev->wl->ieee_stats.dot11FCSErrorCount++;
471 if (macstat & B43_RX_MAC_DECERR) {
472 /* Decryption with the given key failed.
473 * Drop the packet. We also won't be able to decrypt it with
474 * the key in software. */
475 goto drop;
476 }
477
478 /* Skip PLCP and padding */
479 padding = (macstat & B43_RX_MAC_PADDING) ? 2 : 0;
480 if (unlikely(skb->len < (sizeof(struct b43_plcp_hdr6) + padding))) {
481 b43dbg(dev->wl, "RX: Packet size underrun (1)\n");
482 goto drop;
483 }
484 plcp = (struct b43_plcp_hdr6 *)(skb->data + padding);
485 skb_pull(skb, sizeof(struct b43_plcp_hdr6) + padding);
486 /* The skb contains the Wireless Header + payload data now */
487 if (unlikely(skb->len < (2 + 2 + 6 /*minimum hdr */ + FCS_LEN))) {
488 b43dbg(dev->wl, "RX: Packet size underrun (2)\n");
489 goto drop;
490 }
491 wlhdr = (struct ieee80211_hdr *)(skb->data);
492 fctl = le16_to_cpu(wlhdr->frame_control);
e4d6b795
MB
493
494 if (macstat & B43_RX_MAC_DEC) {
495 unsigned int keyidx;
496 int wlhdr_len;
497
498 keyidx = ((macstat & B43_RX_MAC_KEYIDX)
499 >> B43_RX_MAC_KEYIDX_SHIFT);
500 /* We must adjust the key index here. We want the "physical"
501 * key index, but the ucode passed it slightly different.
502 */
503 keyidx = b43_kidx_to_raw(dev, keyidx);
504 B43_WARN_ON(keyidx >= dev->max_nr_keys);
505
506 if (dev->key[keyidx].algorithm != B43_SEC_ALGO_NONE) {
507 wlhdr_len = ieee80211_get_hdrlen(fctl);
508 if (unlikely(skb->len < (wlhdr_len + 3))) {
509 b43dbg(dev->wl,
510 "RX: Packet size underrun (3)\n");
511 goto drop;
512 }
513 status.flag |= RX_FLAG_DECRYPTED;
514 }
515 }
516
517 status.ssi = b43_rssi_postprocess(dev, jssi,
518 (phystat0 & B43_RX_PHYST0_OFDM),
519 (phystat0 & B43_RX_PHYST0_GAINCTL),
520 (phystat3 & B43_RX_PHYST3_TRSTATE));
521 status.noise = dev->stats.link_noise;
522 /* the next line looks wrong, but is what mac80211 wants */
523 status.signal = (jssi * 100) / B43_RX_MAX_SSI;
524 if (phystat0 & B43_RX_PHYST0_OFDM)
525 status.rate = b43_plcp_get_bitrate_ofdm(plcp);
526 else
527 status.rate = b43_plcp_get_bitrate_cck(plcp);
528 status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT);
c0ddd04d
JL
529
530 /*
531 * If monitors are present get full 64-bit timestamp. This
532 * code assumes we get to process the packet within 16 bits
533 * of timestamp, i.e. about 65 milliseconds after the PHY
534 * received the first symbol.
535 */
536 if (dev->wl->radiotap_enabled) {
537 u16 low_mactime_now;
538
539 b43_tsf_read(dev, &status.mactime);
540 low_mactime_now = status.mactime;
541 status.mactime = status.mactime & ~0xFFFFULL;
542 status.mactime += mactime;
543 if (low_mactime_now <= mactime)
544 status.mactime -= 0x10000;
545 status.flag |= RX_FLAG_TSFT;
546 }
e4d6b795
MB
547
548 chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT;
549 switch (chanstat & B43_RX_CHAN_PHYTYPE) {
550 case B43_PHYTYPE_A:
551 status.phymode = MODE_IEEE80211A;
d987160b
MB
552 B43_WARN_ON(1);
553 /* FIXME: We don't really know which value the "chanid" contains.
554 * So the following assignment might be wrong. */
555 status.channel = chanid;
556 status.freq = b43_channel_to_freq_5ghz(status.channel);
e4d6b795
MB
557 break;
558 case B43_PHYTYPE_G:
559 status.phymode = MODE_IEEE80211G;
d987160b
MB
560 /* chanid is the radio channel cookie value as used
561 * to tune the radio. */
e4d6b795 562 status.freq = chanid + 2400;
d987160b
MB
563 status.channel = b43_freq_to_channel_2ghz(status.freq);
564 break;
565 case B43_PHYTYPE_N:
566 status.phymode = 0xDEAD /*FIXME MODE_IEEE80211N*/;
567 /* chanid is the SHM channel cookie. Which is the plain
568 * channel number in b43. */
569 status.channel = chanid;
570 if (chanstat & B43_RX_CHAN_5GHZ)
571 status.freq = b43_freq_to_channel_5ghz(status.freq);
572 else
573 status.freq = b43_freq_to_channel_2ghz(status.freq);
e4d6b795
MB
574 break;
575 default:
576 B43_WARN_ON(1);
d987160b 577 goto drop;
e4d6b795
MB
578 }
579
580 dev->stats.last_rx = jiffies;
581 ieee80211_rx_irqsafe(dev->wl->hw, skb, &status);
582
583 return;
584drop:
585 b43dbg(dev->wl, "RX: Packet dropped\n");
586 dev_kfree_skb_any(skb);
587}
588
589void b43_handle_txstatus(struct b43_wldev *dev,
590 const struct b43_txstatus *status)
591{
592 b43_debugfs_log_txstat(dev, status);
593
594 if (status->intermediate)
595 return;
596 if (status->for_ampdu)
597 return;
598 if (!status->acked)
599 dev->wl->ieee_stats.dot11ACKFailureCount++;
600 if (status->rts_count) {
601 if (status->rts_count == 0xF) //FIXME
602 dev->wl->ieee_stats.dot11RTSFailureCount++;
603 else
604 dev->wl->ieee_stats.dot11RTSSuccessCount++;
605 }
606
03b29773 607 b43_dma_handle_txstatus(dev, status);
e4d6b795
MB
608}
609
610/* Handle TX status report as received through DMA/PIO queues */
611void b43_handle_hwtxstatus(struct b43_wldev *dev,
612 const struct b43_hwtxstatus *hw)
613{
614 struct b43_txstatus status;
615 u8 tmp;
616
617 status.cookie = le16_to_cpu(hw->cookie);
618 status.seq = le16_to_cpu(hw->seq);
619 status.phy_stat = hw->phy_stat;
620 tmp = hw->count;
621 status.frame_count = (tmp >> 4);
622 status.rts_count = (tmp & 0x0F);
623 tmp = hw->flags;
624 status.supp_reason = ((tmp & 0x1C) >> 2);
625 status.pm_indicated = !!(tmp & 0x80);
626 status.intermediate = !!(tmp & 0x40);
627 status.for_ampdu = !!(tmp & 0x20);
628 status.acked = !!(tmp & 0x02);
629
630 b43_handle_txstatus(dev, &status);
631}
632
633/* Stop any TX operation on the device (suspend the hardware queues) */
634void b43_tx_suspend(struct b43_wldev *dev)
635{
03b29773 636 b43_dma_tx_suspend(dev);
e4d6b795
MB
637}
638
639/* Resume any TX operation on the device (resume the hardware queues) */
640void b43_tx_resume(struct b43_wldev *dev)
641{
03b29773 642 b43_dma_tx_resume(dev);
e4d6b795
MB
643}
644
645#if 0
646static void upload_qos_parms(struct b43_wldev *dev,
647 const u16 * parms, u16 offset)
648{
649 int i;
650
651 for (i = 0; i < B43_NR_QOSPARMS; i++) {
652 b43_shm_write16(dev, B43_SHM_SHARED,
653 offset + (i * 2), parms[i]);
654 }
655}
656#endif
657
658/* Initialize the QoS parameters */
659void b43_qos_init(struct b43_wldev *dev)
660{
661 /* FIXME: This function must probably be called from the mac80211
662 * config callback. */
663 return;
664
665 b43_hf_write(dev, b43_hf_read(dev) | B43_HF_EDCF);
666 //FIXME kill magic
667 b43_write16(dev, 0x688, b43_read16(dev, 0x688) | 0x4);
668
669 /*TODO: We might need some stack support here to get the values. */
670}