33 #include <linux/sched.h>
34 #include <linux/slab.h>
50 cookie = (((
u16)q->
index + 1) << 12);
51 cookie |= pack->
index;
63 unsigned int pack_index;
65 switch (cookie & 0xF000) {
84 pack_index = (cookie & 0x0FFF);
87 *pack = &q->
packets[pack_index];
95 static const u16 bases[] = {
105 static const u16 bases_rev11[] = {
114 if (dev->
dev->core_rev >= 11) {
116 return bases_rev11[
index];
124 if (dev->
dev->core_rev >= 11)
131 if (dev->
dev->core_rev >= 11)
147 q->
rev = dev->
dev->core_rev;
148 q->
mmio_base = index_to_pioqueue_base(dev, index) +
149 pio_txqueue_offset(dev);
163 INIT_LIST_HEAD(&p->
list);
181 q->
rev = dev->
dev->core_rev;
182 q->
mmio_base = index_to_pioqueue_base(dev, index) +
183 pio_rxqueue_offset(dev);
210 b43_pio_cancel_tx_packets(q);
222 #define destroy_queue_tx(pio, queue) do { \
223 b43_destroy_pioqueue_tx((pio)->queue, __stringify(queue)); \
224 (pio)->queue = NULL; \
227 #define destroy_queue_rx(pio, queue) do { \
228 b43_destroy_pioqueue_rx((pio)->queue, __stringify(queue)); \
229 (pio)->queue = NULL; \
236 if (!b43_using_pio_transfers(dev))
277 pio->
rx_queue = b43_setup_pioqueue_rx(dev, 0);
279 goto err_destroy_mcast;
281 b43dbg(dev->
wl,
"PIO initialized\n");
307 switch (queue_prio) {
312 q = dev->
pio.tx_queue_AC_VO;
315 q = dev->
pio.tx_queue_AC_VI;
318 q = dev->
pio.tx_queue_AC_BE;
321 q = dev->
pio.tx_queue_AC_BK;
325 q = dev->
pio.tx_queue_AC_BE;
342 b43_block_write(dev, data, (data_len & ~1),
346 u8 *
tail = wl->pio_tailspace;
352 tail[0] = data[data_len - 1];
354 b43_block_write(dev, tail, 2,
366 const char *
frame = pack->
skb->data;
367 unsigned int frame_len = pack->
skb->len;
375 ctl = tx_write_2byte_queue(q, ctl, hdr, hdrlen);
377 ctl = tx_write_2byte_queue(q, ctl, frame, frame_len);
386 unsigned int data_len)
390 const u8 *data = _data;
396 b43_block_write(dev, data, (data_len & ~3),
400 u8 *
tail = wl->pio_tailspace;
407 switch (data_len & 3) {
410 tail[0] = data[data_len - 3];
411 tail[1] = data[data_len - 2];
412 tail[2] = data[data_len - 1];
416 tail[0] = data[data_len - 2];
417 tail[1] = data[data_len - 1];
420 tail[0] = data[data_len - 1];
424 b43_block_write(dev, tail, 4,
436 const char *
frame = pack->
skb->data;
437 unsigned int frame_len = pack->
skb->len;
445 ctl = tx_write_4byte_queue(q, ctl, hdr, hdrlen);
447 ctl = tx_write_4byte_queue(q, ctl, frame, frame_len);
469 cookie = generate_cookie(q, pack);
470 hdrlen = b43_txhdr_size(dev);
472 B43_WARN_ON(
sizeof(wl->pio_scratchspace) < hdrlen);
487 pio_tx_frame_4byte_queue(pack, (
const u8 *)txhdr, hdrlen);
489 pio_tx_frame_2byte_queue(pack, (
const u8 *)txhdr, hdrlen);
514 q = dev->
pio.tx_queue_mcast;
520 q = select_queue_by_priority(dev, skb_get_queue_mapping(skb));
523 hdrlen = b43_txhdr_size(dev);
528 b43dbg(dev->
wl,
"PIO: TX packet longer than queue.\n");
533 b43warn(dev->
wl,
"PIO: TX packet overflow.\n");
551 err = pio_tx_frame(q, skb);
560 b43err(dev->
wl,
"PIO transmission failure\n");
584 q = parse_cookie(dev, status->
cookie, &pack);
589 info = IEEE80211_SKB_CB(pack->
skb);
593 total_len = pack->
skb->len + b43_txhdr_size(dev);
594 total_len =
roundup(total_len, 4);
620 size_t rxhdr_size =
sizeof(*rxhdr);
622 BUILD_BUG_ON(
sizeof(wl->pio_scratchspace) <
sizeof(*rxhdr));
623 switch (dev->
fw.hdr_format) {
626 rxhdr_size -=
sizeof(rxhdr->format_598) -
627 sizeof(rxhdr->format_351);
632 memset(rxhdr, 0, rxhdr_size);
642 B43_PIO8_RXCTL_FRAMERDY);
643 for (i = 0; i < 10; i++) {
656 B43_PIO_RXCTL_FRAMERDY);
657 for (i = 0; i < 10; i++) {
664 b43dbg(q->
dev->wl,
"PIO RX timed out\n");
670 b43_block_read(dev, rxhdr, rxhdr_size,
674 b43_block_read(dev, rxhdr, rxhdr_size,
681 err_msg =
"len > 0x700";
685 err_msg =
"len == 0";
689 switch (dev->
fw.hdr_format) {
701 err_msg =
"Frame FCS error";
710 skb = dev_alloc_skb(len + padding + 2);
712 err_msg =
"Out of memory";
718 b43_block_read(dev, skb->
data + padding, (len & ~3),
722 u8 *tail = wl->pio_tailspace;
726 b43_block_read(dev, tail, 4,
731 skb->
data[len + padding - 3] = tail[0];
732 skb->
data[len + padding - 2] = tail[1];
733 skb->
data[len + padding - 1] = tail[2];
736 skb->
data[len + padding - 2] = tail[0];
737 skb->
data[len + padding - 1] = tail[1];
740 skb->
data[len + padding - 1] = tail[0];
745 b43_block_read(dev, skb->
data + padding, (len & ~1),
749 u8 *tail = wl->pio_tailspace;
753 b43_block_read(dev, tail, 2,
756 skb->
data[len + padding - 1] = tail[0];
766 b43dbg(q->
dev->wl,
"PIO RX error: %s\n", err_msg);
777 unsigned int count = 0;
781 stop = (pio_rx_frame(q) == 0);
819 b43_pio_tx_suspend_queue(dev->
pio.tx_queue_AC_BK);
820 b43_pio_tx_suspend_queue(dev->
pio.tx_queue_AC_BE);
821 b43_pio_tx_suspend_queue(dev->
pio.tx_queue_AC_VI);
822 b43_pio_tx_suspend_queue(dev->
pio.tx_queue_AC_VO);
823 b43_pio_tx_suspend_queue(dev->
pio.tx_queue_mcast);
828 b43_pio_tx_resume_queue(dev->
pio.tx_queue_mcast);
829 b43_pio_tx_resume_queue(dev->
pio.tx_queue_AC_VO);
830 b43_pio_tx_resume_queue(dev->
pio.tx_queue_AC_VI);
831 b43_pio_tx_resume_queue(dev->
pio.tx_queue_AC_BE);
832 b43_pio_tx_resume_queue(dev->
pio.tx_queue_AC_BK);