pio.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*
  2. Broadcom B43legacy wireless driver
  3. PIO Transmission
  4. Copyright (c) 2005 Michael Buesch <m@bues.ch>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; see the file COPYING. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #include "b43legacy.h"
  19. #include "pio.h"
  20. #include "main.h"
  21. #include "xmit.h"
  22. #include <linux/delay.h>
  23. #include <linux/slab.h>
  24. static void tx_start(struct b43legacy_pioqueue *queue)
  25. {
  26. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  27. B43legacy_PIO_TXCTL_INIT);
  28. }
  29. static void tx_octet(struct b43legacy_pioqueue *queue,
  30. u8 octet)
  31. {
  32. if (queue->need_workarounds) {
  33. b43legacy_pio_write(queue, B43legacy_PIO_TXDATA, octet);
  34. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  35. B43legacy_PIO_TXCTL_WRITELO);
  36. } else {
  37. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  38. B43legacy_PIO_TXCTL_WRITELO);
  39. b43legacy_pio_write(queue, B43legacy_PIO_TXDATA, octet);
  40. }
  41. }
  42. static u16 tx_get_next_word(const u8 *txhdr,
  43. const u8 *packet,
  44. size_t txhdr_size,
  45. unsigned int *pos)
  46. {
  47. const u8 *source;
  48. unsigned int i = *pos;
  49. u16 ret;
  50. if (i < txhdr_size)
  51. source = txhdr;
  52. else {
  53. source = packet;
  54. i -= txhdr_size;
  55. }
  56. ret = le16_to_cpu(*((__le16 *)(source + i)));
  57. *pos += 2;
  58. return ret;
  59. }
  60. static void tx_data(struct b43legacy_pioqueue *queue,
  61. u8 *txhdr,
  62. const u8 *packet,
  63. unsigned int octets)
  64. {
  65. u16 data;
  66. unsigned int i = 0;
  67. if (queue->need_workarounds) {
  68. data = tx_get_next_word(txhdr, packet,
  69. sizeof(struct b43legacy_txhdr_fw3), &i);
  70. b43legacy_pio_write(queue, B43legacy_PIO_TXDATA, data);
  71. }
  72. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  73. B43legacy_PIO_TXCTL_WRITELO |
  74. B43legacy_PIO_TXCTL_WRITEHI);
  75. while (i < octets - 1) {
  76. data = tx_get_next_word(txhdr, packet,
  77. sizeof(struct b43legacy_txhdr_fw3), &i);
  78. b43legacy_pio_write(queue, B43legacy_PIO_TXDATA, data);
  79. }
  80. if (octets % 2)
  81. tx_octet(queue, packet[octets -
  82. sizeof(struct b43legacy_txhdr_fw3) - 1]);
  83. }
  84. static void tx_complete(struct b43legacy_pioqueue *queue,
  85. struct sk_buff *skb)
  86. {
  87. if (queue->need_workarounds) {
  88. b43legacy_pio_write(queue, B43legacy_PIO_TXDATA,
  89. skb->data[skb->len - 1]);
  90. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  91. B43legacy_PIO_TXCTL_WRITELO |
  92. B43legacy_PIO_TXCTL_COMPLETE);
  93. } else
  94. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  95. B43legacy_PIO_TXCTL_COMPLETE);
  96. }
  97. static u16 generate_cookie(struct b43legacy_pioqueue *queue,
  98. struct b43legacy_pio_txpacket *packet)
  99. {
  100. u16 cookie = 0x0000;
  101. int packetindex;
  102. /* We use the upper 4 bits for the PIO
  103. * controller ID and the lower 12 bits
  104. * for the packet index (in the cache).
  105. */
  106. switch (queue->mmio_base) {
  107. case B43legacy_MMIO_PIO1_BASE:
  108. break;
  109. case B43legacy_MMIO_PIO2_BASE:
  110. cookie = 0x1000;
  111. break;
  112. case B43legacy_MMIO_PIO3_BASE:
  113. cookie = 0x2000;
  114. break;
  115. case B43legacy_MMIO_PIO4_BASE:
  116. cookie = 0x3000;
  117. break;
  118. default:
  119. B43legacy_WARN_ON(1);
  120. }
  121. packetindex = pio_txpacket_getindex(packet);
  122. B43legacy_WARN_ON(!(((u16)packetindex & 0xF000) == 0x0000));
  123. cookie |= (u16)packetindex;
  124. return cookie;
  125. }
  126. static
  127. struct b43legacy_pioqueue *parse_cookie(struct b43legacy_wldev *dev,
  128. u16 cookie,
  129. struct b43legacy_pio_txpacket **packet)
  130. {
  131. struct b43legacy_pio *pio = &dev->pio;
  132. struct b43legacy_pioqueue *queue = NULL;
  133. int packetindex;
  134. switch (cookie & 0xF000) {
  135. case 0x0000:
  136. queue = pio->queue0;
  137. break;
  138. case 0x1000:
  139. queue = pio->queue1;
  140. break;
  141. case 0x2000:
  142. queue = pio->queue2;
  143. break;
  144. case 0x3000:
  145. queue = pio->queue3;
  146. break;
  147. default:
  148. B43legacy_WARN_ON(1);
  149. }
  150. packetindex = (cookie & 0x0FFF);
  151. B43legacy_WARN_ON(!(packetindex >= 0 && packetindex
  152. < B43legacy_PIO_MAXTXPACKETS));
  153. *packet = &(queue->tx_packets_cache[packetindex]);
  154. return queue;
  155. }
  156. union txhdr_union {
  157. struct b43legacy_txhdr_fw3 txhdr_fw3;
  158. };
  159. static int pio_tx_write_fragment(struct b43legacy_pioqueue *queue,
  160. struct sk_buff *skb,
  161. struct b43legacy_pio_txpacket *packet,
  162. size_t txhdr_size)
  163. {
  164. union txhdr_union txhdr_data;
  165. u8 *txhdr = NULL;
  166. unsigned int octets;
  167. int err;
  168. txhdr = (u8 *)(&txhdr_data.txhdr_fw3);
  169. B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0);
  170. err = b43legacy_generate_txhdr(queue->dev,
  171. txhdr, skb->data, skb->len,
  172. IEEE80211_SKB_CB(skb),
  173. generate_cookie(queue, packet));
  174. if (err)
  175. return err;
  176. tx_start(queue);
  177. octets = skb->len + txhdr_size;
  178. if (queue->need_workarounds)
  179. octets--;
  180. tx_data(queue, txhdr, (u8 *)skb->data, octets);
  181. tx_complete(queue, skb);
  182. return 0;
  183. }
  184. static void free_txpacket(struct b43legacy_pio_txpacket *packet,
  185. int irq_context)
  186. {
  187. struct b43legacy_pioqueue *queue = packet->queue;
  188. if (packet->skb) {
  189. if (irq_context)
  190. dev_kfree_skb_irq(packet->skb);
  191. else
  192. dev_kfree_skb(packet->skb);
  193. }
  194. list_move(&packet->list, &queue->txfree);
  195. queue->nr_txfree++;
  196. }
  197. static int pio_tx_packet(struct b43legacy_pio_txpacket *packet)
  198. {
  199. struct b43legacy_pioqueue *queue = packet->queue;
  200. struct sk_buff *skb = packet->skb;
  201. u16 octets;
  202. int err;
  203. octets = (u16)skb->len + sizeof(struct b43legacy_txhdr_fw3);
  204. if (queue->tx_devq_size < octets) {
  205. b43legacywarn(queue->dev->wl, "PIO queue too small. "
  206. "Dropping packet.\n");
  207. /* Drop it silently (return success) */
  208. free_txpacket(packet, 1);
  209. return 0;
  210. }
  211. B43legacy_WARN_ON(queue->tx_devq_packets >
  212. B43legacy_PIO_MAXTXDEVQPACKETS);
  213. B43legacy_WARN_ON(queue->tx_devq_used > queue->tx_devq_size);
  214. /* Check if there is sufficient free space on the device
  215. * TX queue. If not, return and let the TX tasklet
  216. * retry later.
  217. */
  218. if (queue->tx_devq_packets == B43legacy_PIO_MAXTXDEVQPACKETS)
  219. return -EBUSY;
  220. if (queue->tx_devq_used + octets > queue->tx_devq_size)
  221. return -EBUSY;
  222. /* Now poke the device. */
  223. err = pio_tx_write_fragment(queue, skb, packet,
  224. sizeof(struct b43legacy_txhdr_fw3));
  225. if (unlikely(err == -ENOKEY)) {
  226. /* Drop this packet, as we don't have the encryption key
  227. * anymore and must not transmit it unencrypted. */
  228. free_txpacket(packet, 1);
  229. return 0;
  230. }
  231. /* Account for the packet size.
  232. * (We must not overflow the device TX queue)
  233. */
  234. queue->tx_devq_packets++;
  235. queue->tx_devq_used += octets;
  236. /* Transmission started, everything ok, move the
  237. * packet to the txrunning list.
  238. */
  239. list_move_tail(&packet->list, &queue->txrunning);
  240. return 0;
  241. }
  242. static void tx_tasklet(unsigned long d)
  243. {
  244. struct b43legacy_pioqueue *queue = (struct b43legacy_pioqueue *)d;
  245. struct b43legacy_wldev *dev = queue->dev;
  246. unsigned long flags;
  247. struct b43legacy_pio_txpacket *packet, *tmp_packet;
  248. int err;
  249. u16 txctl;
  250. spin_lock_irqsave(&dev->wl->irq_lock, flags);
  251. if (queue->tx_frozen)
  252. goto out_unlock;
  253. txctl = b43legacy_pio_read(queue, B43legacy_PIO_TXCTL);
  254. if (txctl & B43legacy_PIO_TXCTL_SUSPEND)
  255. goto out_unlock;
  256. list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) {
  257. /* Try to transmit the packet. This can fail, if
  258. * the device queue is full. In case of failure, the
  259. * packet is left in the txqueue.
  260. * If transmission succeed, the packet is moved to txrunning.
  261. * If it is impossible to transmit the packet, it
  262. * is dropped.
  263. */
  264. err = pio_tx_packet(packet);
  265. if (err)
  266. break;
  267. }
  268. out_unlock:
  269. spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
  270. }
  271. static void setup_txqueues(struct b43legacy_pioqueue *queue)
  272. {
  273. struct b43legacy_pio_txpacket *packet;
  274. int i;
  275. queue->nr_txfree = B43legacy_PIO_MAXTXPACKETS;
  276. for (i = 0; i < B43legacy_PIO_MAXTXPACKETS; i++) {
  277. packet = &(queue->tx_packets_cache[i]);
  278. packet->queue = queue;
  279. INIT_LIST_HEAD(&packet->list);
  280. list_add(&packet->list, &queue->txfree);
  281. }
  282. }
  283. static
  284. struct b43legacy_pioqueue *b43legacy_setup_pioqueue(struct b43legacy_wldev *dev,
  285. u16 pio_mmio_base)
  286. {
  287. struct b43legacy_pioqueue *queue;
  288. u32 value;
  289. u16 qsize;
  290. queue = kzalloc(sizeof(*queue), GFP_KERNEL);
  291. if (!queue)
  292. goto out;
  293. queue->dev = dev;
  294. queue->mmio_base = pio_mmio_base;
  295. queue->need_workarounds = (dev->dev->id.revision < 3);
  296. INIT_LIST_HEAD(&queue->txfree);
  297. INIT_LIST_HEAD(&queue->txqueue);
  298. INIT_LIST_HEAD(&queue->txrunning);
  299. tasklet_init(&queue->txtask, tx_tasklet,
  300. (unsigned long)queue);
  301. value = b43legacy_read32(dev, B43legacy_MMIO_MACCTL);
  302. value &= ~B43legacy_MACCTL_BE;
  303. b43legacy_write32(dev, B43legacy_MMIO_MACCTL, value);
  304. qsize = b43legacy_read16(dev, queue->mmio_base
  305. + B43legacy_PIO_TXQBUFSIZE);
  306. if (qsize == 0) {
  307. b43legacyerr(dev->wl, "This card does not support PIO "
  308. "operation mode. Please use DMA mode "
  309. "(module parameter pio=0).\n");
  310. goto err_freequeue;
  311. }
  312. if (qsize <= B43legacy_PIO_TXQADJUST) {
  313. b43legacyerr(dev->wl, "PIO tx device-queue too small (%u)\n",
  314. qsize);
  315. goto err_freequeue;
  316. }
  317. qsize -= B43legacy_PIO_TXQADJUST;
  318. queue->tx_devq_size = qsize;
  319. setup_txqueues(queue);
  320. out:
  321. return queue;
  322. err_freequeue:
  323. kfree(queue);
  324. queue = NULL;
  325. goto out;
  326. }
  327. static void cancel_transfers(struct b43legacy_pioqueue *queue)
  328. {
  329. struct b43legacy_pio_txpacket *packet, *tmp_packet;
  330. tasklet_kill(&queue->txtask);
  331. list_for_each_entry_safe(packet, tmp_packet, &queue->txrunning, list)
  332. free_txpacket(packet, 0);
  333. list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list)
  334. free_txpacket(packet, 0);
  335. }
  336. static void b43legacy_destroy_pioqueue(struct b43legacy_pioqueue *queue)
  337. {
  338. if (!queue)
  339. return;
  340. cancel_transfers(queue);
  341. kfree(queue);
  342. }
  343. void b43legacy_pio_free(struct b43legacy_wldev *dev)
  344. {
  345. struct b43legacy_pio *pio;
  346. if (!b43legacy_using_pio(dev))
  347. return;
  348. pio = &dev->pio;
  349. b43legacy_destroy_pioqueue(pio->queue3);
  350. pio->queue3 = NULL;
  351. b43legacy_destroy_pioqueue(pio->queue2);
  352. pio->queue2 = NULL;
  353. b43legacy_destroy_pioqueue(pio->queue1);
  354. pio->queue1 = NULL;
  355. b43legacy_destroy_pioqueue(pio->queue0);
  356. pio->queue0 = NULL;
  357. }
  358. int b43legacy_pio_init(struct b43legacy_wldev *dev)
  359. {
  360. struct b43legacy_pio *pio = &dev->pio;
  361. struct b43legacy_pioqueue *queue;
  362. int err = -ENOMEM;
  363. queue = b43legacy_setup_pioqueue(dev, B43legacy_MMIO_PIO1_BASE);
  364. if (!queue)
  365. goto out;
  366. pio->queue0 = queue;
  367. queue = b43legacy_setup_pioqueue(dev, B43legacy_MMIO_PIO2_BASE);
  368. if (!queue)
  369. goto err_destroy0;
  370. pio->queue1 = queue;
  371. queue = b43legacy_setup_pioqueue(dev, B43legacy_MMIO_PIO3_BASE);
  372. if (!queue)
  373. goto err_destroy1;
  374. pio->queue2 = queue;
  375. queue = b43legacy_setup_pioqueue(dev, B43legacy_MMIO_PIO4_BASE);
  376. if (!queue)
  377. goto err_destroy2;
  378. pio->queue3 = queue;
  379. if (dev->dev->id.revision < 3)
  380. dev->irq_mask |= B43legacy_IRQ_PIO_WORKAROUND;
  381. b43legacydbg(dev->wl, "PIO initialized\n");
  382. err = 0;
  383. out:
  384. return err;
  385. err_destroy2:
  386. b43legacy_destroy_pioqueue(pio->queue2);
  387. pio->queue2 = NULL;
  388. err_destroy1:
  389. b43legacy_destroy_pioqueue(pio->queue1);
  390. pio->queue1 = NULL;
  391. err_destroy0:
  392. b43legacy_destroy_pioqueue(pio->queue0);
  393. pio->queue0 = NULL;
  394. goto out;
  395. }
  396. int b43legacy_pio_tx(struct b43legacy_wldev *dev,
  397. struct sk_buff *skb)
  398. {
  399. struct b43legacy_pioqueue *queue = dev->pio.queue1;
  400. struct b43legacy_pio_txpacket *packet;
  401. B43legacy_WARN_ON(queue->tx_suspended);
  402. B43legacy_WARN_ON(list_empty(&queue->txfree));
  403. packet = list_entry(queue->txfree.next, struct b43legacy_pio_txpacket,
  404. list);
  405. packet->skb = skb;
  406. list_move_tail(&packet->list, &queue->txqueue);
  407. queue->nr_txfree--;
  408. B43legacy_WARN_ON(queue->nr_txfree >= B43legacy_PIO_MAXTXPACKETS);
  409. tasklet_schedule(&queue->txtask);
  410. return 0;
  411. }
  412. void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
  413. const struct b43legacy_txstatus *status)
  414. {
  415. struct b43legacy_pioqueue *queue;
  416. struct b43legacy_pio_txpacket *packet;
  417. struct ieee80211_tx_info *info;
  418. int retry_limit;
  419. queue = parse_cookie(dev, status->cookie, &packet);
  420. B43legacy_WARN_ON(!queue);
  421. if (!packet->skb)
  422. return;
  423. queue->tx_devq_packets--;
  424. queue->tx_devq_used -= (packet->skb->len +
  425. sizeof(struct b43legacy_txhdr_fw3));
  426. info = IEEE80211_SKB_CB(packet->skb);
  427. /* preserve the confiured retry limit before clearing the status
  428. * The xmit function has overwritten the rc's value with the actual
  429. * retry limit done by the hardware */
  430. retry_limit = info->status.rates[0].count;
  431. ieee80211_tx_info_clear_status(info);
  432. if (status->acked)
  433. info->flags |= IEEE80211_TX_STAT_ACK;
  434. if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) {
  435. /*
  436. * If the short retries (RTS, not data frame) have exceeded
  437. * the limit, the hw will not have tried the selected rate,
  438. * but will have used the fallback rate instead.
  439. * Don't let the rate control count attempts for the selected
  440. * rate in this case, otherwise the statistics will be off.
  441. */
  442. info->status.rates[0].count = 0;
  443. info->status.rates[1].count = status->frame_count;
  444. } else {
  445. if (status->frame_count > retry_limit) {
  446. info->status.rates[0].count = retry_limit;
  447. info->status.rates[1].count = status->frame_count -
  448. retry_limit;
  449. } else {
  450. info->status.rates[0].count = status->frame_count;
  451. info->status.rates[1].idx = -1;
  452. }
  453. }
  454. ieee80211_tx_status_irqsafe(dev->wl->hw, packet->skb);
  455. packet->skb = NULL;
  456. free_txpacket(packet, 1);
  457. /* If there are packets on the txqueue, poke the tasklet
  458. * to transmit them.
  459. */
  460. if (!list_empty(&queue->txqueue))
  461. tasklet_schedule(&queue->txtask);
  462. }
  463. static void pio_rx_error(struct b43legacy_pioqueue *queue,
  464. int clear_buffers,
  465. const char *error)
  466. {
  467. int i;
  468. b43legacyerr(queue->dev->wl, "PIO RX error: %s\n", error);
  469. b43legacy_pio_write(queue, B43legacy_PIO_RXCTL,
  470. B43legacy_PIO_RXCTL_READY);
  471. if (clear_buffers) {
  472. B43legacy_WARN_ON(queue->mmio_base != B43legacy_MMIO_PIO1_BASE);
  473. for (i = 0; i < 15; i++) {
  474. /* Dummy read. */
  475. b43legacy_pio_read(queue, B43legacy_PIO_RXDATA);
  476. }
  477. }
  478. }
  479. void b43legacy_pio_rx(struct b43legacy_pioqueue *queue)
  480. {
  481. __le16 preamble[21] = { 0 };
  482. struct b43legacy_rxhdr_fw3 *rxhdr;
  483. u16 tmp;
  484. u16 len;
  485. u16 macstat;
  486. int i;
  487. int preamble_readwords;
  488. struct sk_buff *skb;
  489. tmp = b43legacy_pio_read(queue, B43legacy_PIO_RXCTL);
  490. if (!(tmp & B43legacy_PIO_RXCTL_DATAAVAILABLE))
  491. return;
  492. b43legacy_pio_write(queue, B43legacy_PIO_RXCTL,
  493. B43legacy_PIO_RXCTL_DATAAVAILABLE);
  494. for (i = 0; i < 10; i++) {
  495. tmp = b43legacy_pio_read(queue, B43legacy_PIO_RXCTL);
  496. if (tmp & B43legacy_PIO_RXCTL_READY)
  497. goto data_ready;
  498. udelay(10);
  499. }
  500. b43legacydbg(queue->dev->wl, "PIO RX timed out\n");
  501. return;
  502. data_ready:
  503. len = b43legacy_pio_read(queue, B43legacy_PIO_RXDATA);
  504. if (unlikely(len > 0x700)) {
  505. pio_rx_error(queue, 0, "len > 0x700");
  506. return;
  507. }
  508. if (unlikely(len == 0 && queue->mmio_base !=
  509. B43legacy_MMIO_PIO4_BASE)) {
  510. pio_rx_error(queue, 0, "len == 0");
  511. return;
  512. }
  513. preamble[0] = cpu_to_le16(len);
  514. if (queue->mmio_base == B43legacy_MMIO_PIO4_BASE)
  515. preamble_readwords = 14 / sizeof(u16);
  516. else
  517. preamble_readwords = 18 / sizeof(u16);
  518. for (i = 0; i < preamble_readwords; i++) {
  519. tmp = b43legacy_pio_read(queue, B43legacy_PIO_RXDATA);
  520. preamble[i + 1] = cpu_to_le16(tmp);
  521. }
  522. rxhdr = (struct b43legacy_rxhdr_fw3 *)preamble;
  523. macstat = le16_to_cpu(rxhdr->mac_status);
  524. if (macstat & B43legacy_RX_MAC_FCSERR) {
  525. pio_rx_error(queue,
  526. (queue->mmio_base == B43legacy_MMIO_PIO1_BASE),
  527. "Frame FCS error");
  528. return;
  529. }
  530. if (queue->mmio_base == B43legacy_MMIO_PIO4_BASE) {
  531. /* We received an xmit status. */
  532. struct b43legacy_hwtxstatus *hw;
  533. hw = (struct b43legacy_hwtxstatus *)(preamble + 1);
  534. b43legacy_handle_hwtxstatus(queue->dev, hw);
  535. return;
  536. }
  537. skb = dev_alloc_skb(len);
  538. if (unlikely(!skb)) {
  539. pio_rx_error(queue, 1, "OOM");
  540. return;
  541. }
  542. skb_put(skb, len);
  543. for (i = 0; i < len - 1; i += 2) {
  544. tmp = b43legacy_pio_read(queue, B43legacy_PIO_RXDATA);
  545. *((__le16 *)(skb->data + i)) = cpu_to_le16(tmp);
  546. }
  547. if (len % 2) {
  548. tmp = b43legacy_pio_read(queue, B43legacy_PIO_RXDATA);
  549. skb->data[len - 1] = (tmp & 0x00FF);
  550. }
  551. b43legacy_rx(queue->dev, skb, rxhdr);
  552. }
  553. void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue)
  554. {
  555. b43legacy_power_saving_ctl_bits(queue->dev, -1, 1);
  556. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  557. b43legacy_pio_read(queue, B43legacy_PIO_TXCTL)
  558. | B43legacy_PIO_TXCTL_SUSPEND);
  559. }
  560. void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue)
  561. {
  562. b43legacy_pio_write(queue, B43legacy_PIO_TXCTL,
  563. b43legacy_pio_read(queue, B43legacy_PIO_TXCTL)
  564. & ~B43legacy_PIO_TXCTL_SUSPEND);
  565. b43legacy_power_saving_ctl_bits(queue->dev, -1, -1);
  566. tasklet_schedule(&queue->txtask);
  567. }
  568. void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev)
  569. {
  570. struct b43legacy_pio *pio;
  571. B43legacy_WARN_ON(!b43legacy_using_pio(dev));
  572. pio = &dev->pio;
  573. pio->queue0->tx_frozen = 1;
  574. pio->queue1->tx_frozen = 1;
  575. pio->queue2->tx_frozen = 1;
  576. pio->queue3->tx_frozen = 1;
  577. }
  578. void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev)
  579. {
  580. struct b43legacy_pio *pio;
  581. B43legacy_WARN_ON(!b43legacy_using_pio(dev));
  582. pio = &dev->pio;
  583. pio->queue0->tx_frozen = 0;
  584. pio->queue1->tx_frozen = 0;
  585. pio->queue2->tx_frozen = 0;
  586. pio->queue3->tx_frozen = 0;
  587. if (!list_empty(&pio->queue0->txqueue))
  588. tasklet_schedule(&pio->queue0->txtask);
  589. if (!list_empty(&pio->queue1->txqueue))
  590. tasklet_schedule(&pio->queue1->txtask);
  591. if (!list_empty(&pio->queue2->txqueue))
  592. tasklet_schedule(&pio->queue2->txtask);
  593. if (!list_empty(&pio->queue3->txqueue))
  594. tasklet_schedule(&pio->queue3->txtask);
  595. }