John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Broadcom BCM43xx wireless driver |
| 4 | |
| 5 | PIO Transmission |
| 6 | |
| 7 | Copyright (c) 2005 Michael Buesch <mbuesch@freenet.de> |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; see the file COPYING. If not, write to |
| 21 | the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, |
| 22 | Boston, MA 02110-1301, USA. |
| 23 | |
| 24 | */ |
| 25 | |
| 26 | #include "bcm43xx.h" |
| 27 | #include "bcm43xx_pio.h" |
| 28 | #include "bcm43xx_main.h" |
Michael Buesch | f398f02 | 2006-02-23 21:15:39 +0100 | [diff] [blame] | 29 | #include "bcm43xx_xmit.h" |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 30 | #include "bcm43xx_power.h" |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 31 | |
| 32 | #include <linux/delay.h> |
| 33 | |
| 34 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 35 | static void tx_start(struct bcm43xx_pioqueue *queue) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 36 | { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 37 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
| 38 | BCM43xx_PIO_TXCTL_INIT); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 39 | } |
| 40 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 41 | static void tx_octet(struct bcm43xx_pioqueue *queue, |
| 42 | u8 octet) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 43 | { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 44 | if (queue->need_workarounds) { |
| 45 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, |
| 46 | octet); |
| 47 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 48 | BCM43xx_PIO_TXCTL_WRITELO); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 49 | } else { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 50 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 51 | BCM43xx_PIO_TXCTL_WRITELO); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 52 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, |
| 53 | octet); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 57 | static u16 tx_get_next_word(struct bcm43xx_txhdr *txhdr, |
| 58 | const u8 *packet, |
| 59 | unsigned int *pos) |
| 60 | { |
| 61 | const u8 *source; |
| 62 | unsigned int i = *pos; |
| 63 | u16 ret; |
| 64 | |
| 65 | if (i < sizeof(*txhdr)) { |
| 66 | source = (const u8 *)txhdr; |
| 67 | } else { |
| 68 | source = packet; |
| 69 | i -= sizeof(*txhdr); |
| 70 | } |
| 71 | ret = le16_to_cpu( *((u16 *)(source + i)) ); |
| 72 | *pos += 2; |
| 73 | |
| 74 | return ret; |
| 75 | } |
| 76 | |
| 77 | static void tx_data(struct bcm43xx_pioqueue *queue, |
| 78 | struct bcm43xx_txhdr *txhdr, |
| 79 | const u8 *packet, |
| 80 | unsigned int octets) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 81 | { |
| 82 | u16 data; |
| 83 | unsigned int i = 0; |
| 84 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 85 | if (queue->need_workarounds) { |
| 86 | data = tx_get_next_word(txhdr, packet, &i); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 87 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, data); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 88 | } |
| 89 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 90 | BCM43xx_PIO_TXCTL_WRITELO | |
| 91 | BCM43xx_PIO_TXCTL_WRITEHI); |
| 92 | while (i < octets - 1) { |
| 93 | data = tx_get_next_word(txhdr, packet, &i); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 94 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, data); |
| 95 | } |
| 96 | if (octets % 2) |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 97 | tx_octet(queue, packet[octets - sizeof(*txhdr) - 1]); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 98 | } |
| 99 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 100 | static void tx_complete(struct bcm43xx_pioqueue *queue, |
| 101 | struct sk_buff *skb) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 102 | { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 103 | if (queue->need_workarounds) { |
| 104 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, |
| 105 | skb->data[skb->len - 1]); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 106 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 107 | BCM43xx_PIO_TXCTL_WRITELO | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 108 | BCM43xx_PIO_TXCTL_COMPLETE); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 109 | } else { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 110 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
| 111 | BCM43xx_PIO_TXCTL_COMPLETE); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 115 | static u16 generate_cookie(struct bcm43xx_pioqueue *queue, |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 116 | struct bcm43xx_pio_txpacket *packet) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 117 | { |
| 118 | u16 cookie = 0x0000; |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 119 | int packetindex; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 120 | |
| 121 | /* We use the upper 4 bits for the PIO |
| 122 | * controller ID and the lower 12 bits |
| 123 | * for the packet index (in the cache). |
| 124 | */ |
| 125 | switch (queue->mmio_base) { |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 126 | case BCM43xx_MMIO_PIO1_BASE: |
| 127 | break; |
| 128 | case BCM43xx_MMIO_PIO2_BASE: |
| 129 | cookie = 0x1000; |
| 130 | break; |
| 131 | case BCM43xx_MMIO_PIO3_BASE: |
| 132 | cookie = 0x2000; |
| 133 | break; |
| 134 | case BCM43xx_MMIO_PIO4_BASE: |
| 135 | cookie = 0x3000; |
| 136 | break; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 137 | default: |
| 138 | assert(0); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 139 | } |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 140 | packetindex = pio_txpacket_getindex(packet); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 141 | assert(((u16)packetindex & 0xF000) == 0x0000); |
| 142 | cookie |= (u16)packetindex; |
| 143 | |
| 144 | return cookie; |
| 145 | } |
| 146 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 147 | static |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 148 | struct bcm43xx_pioqueue * parse_cookie(struct bcm43xx_private *bcm, |
| 149 | u16 cookie, |
| 150 | struct bcm43xx_pio_txpacket **packet) |
| 151 | { |
Michael Buesch | e9357c0 | 2006-03-13 19:27:34 +0100 | [diff] [blame] | 152 | struct bcm43xx_pio *pio = bcm43xx_current_pio(bcm); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 153 | struct bcm43xx_pioqueue *queue = NULL; |
| 154 | int packetindex; |
| 155 | |
| 156 | switch (cookie & 0xF000) { |
| 157 | case 0x0000: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 158 | queue = pio->queue0; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 159 | break; |
| 160 | case 0x1000: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 161 | queue = pio->queue1; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 162 | break; |
| 163 | case 0x2000: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 164 | queue = pio->queue2; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 165 | break; |
| 166 | case 0x3000: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 167 | queue = pio->queue3; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 168 | break; |
| 169 | default: |
| 170 | assert(0); |
| 171 | } |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 172 | packetindex = (cookie & 0x0FFF); |
| 173 | assert(packetindex >= 0 && packetindex < BCM43xx_PIO_MAXTXPACKETS); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 174 | *packet = &(queue->tx_packets_cache[packetindex]); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 175 | |
| 176 | return queue; |
| 177 | } |
| 178 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 179 | static void pio_tx_write_fragment(struct bcm43xx_pioqueue *queue, |
| 180 | struct sk_buff *skb, |
| 181 | struct bcm43xx_pio_txpacket *packet) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 182 | { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 183 | struct bcm43xx_txhdr txhdr; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 184 | unsigned int octets; |
| 185 | |
| 186 | assert(skb_shinfo(skb)->nr_frags == 0); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 187 | bcm43xx_generate_txhdr(queue->bcm, |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 188 | &txhdr, skb->data, skb->len, |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 189 | (packet->xmitted_frags == 0), |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 190 | generate_cookie(queue, packet)); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 191 | |
| 192 | tx_start(queue); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 193 | octets = skb->len + sizeof(txhdr); |
| 194 | if (queue->need_workarounds) |
| 195 | octets--; |
| 196 | tx_data(queue, &txhdr, (u8 *)skb->data, octets); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 197 | tx_complete(queue, skb); |
| 198 | } |
| 199 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 200 | static void free_txpacket(struct bcm43xx_pio_txpacket *packet, |
| 201 | int irq_context) |
| 202 | { |
| 203 | struct bcm43xx_pioqueue *queue = packet->queue; |
| 204 | |
| 205 | ieee80211_txb_free(packet->txb); |
| 206 | list_move(&packet->list, &queue->txfree); |
| 207 | queue->nr_txfree++; |
| 208 | |
| 209 | assert(queue->tx_devq_used >= packet->xmitted_octets); |
| 210 | assert(queue->tx_devq_packets >= packet->xmitted_frags); |
| 211 | queue->tx_devq_used -= packet->xmitted_octets; |
| 212 | queue->tx_devq_packets -= packet->xmitted_frags; |
| 213 | } |
| 214 | |
| 215 | static int pio_tx_packet(struct bcm43xx_pio_txpacket *packet) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 216 | { |
| 217 | struct bcm43xx_pioqueue *queue = packet->queue; |
| 218 | struct ieee80211_txb *txb = packet->txb; |
| 219 | struct sk_buff *skb; |
| 220 | u16 octets; |
| 221 | int i; |
| 222 | |
| 223 | for (i = packet->xmitted_frags; i < txb->nr_frags; i++) { |
| 224 | skb = txb->fragments[i]; |
| 225 | |
| 226 | octets = (u16)skb->len + sizeof(struct bcm43xx_txhdr); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 227 | assert(queue->tx_devq_size >= octets); |
| 228 | assert(queue->tx_devq_packets <= BCM43xx_PIO_MAXTXDEVQPACKETS); |
| 229 | assert(queue->tx_devq_used <= queue->tx_devq_size); |
| 230 | /* Check if there is sufficient free space on the device |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 231 | * TX queue. If not, return and let the TX tasklet |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 232 | * retry later. |
| 233 | */ |
| 234 | if (queue->tx_devq_packets == BCM43xx_PIO_MAXTXDEVQPACKETS) |
| 235 | return -EBUSY; |
| 236 | if (queue->tx_devq_used + octets > queue->tx_devq_size) |
| 237 | return -EBUSY; |
| 238 | /* Now poke the device. */ |
| 239 | pio_tx_write_fragment(queue, skb, packet); |
| 240 | |
| 241 | /* Account for the packet size. |
| 242 | * (We must not overflow the device TX queue) |
| 243 | */ |
| 244 | queue->tx_devq_packets++; |
| 245 | queue->tx_devq_used += octets; |
| 246 | |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 247 | assert(packet->xmitted_frags < packet->txb->nr_frags); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 248 | packet->xmitted_frags++; |
| 249 | packet->xmitted_octets += octets; |
| 250 | } |
| 251 | list_move_tail(&packet->list, &queue->txrunning); |
| 252 | |
| 253 | return 0; |
| 254 | } |
| 255 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 256 | static void tx_tasklet(unsigned long d) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 257 | { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 258 | struct bcm43xx_pioqueue *queue = (struct bcm43xx_pioqueue *)d; |
| 259 | struct bcm43xx_private *bcm = queue->bcm; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 260 | unsigned long flags; |
| 261 | struct bcm43xx_pio_txpacket *packet, *tmp_packet; |
| 262 | int err; |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 263 | u16 txctl; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 264 | |
Michael Buesch | 78ff56a | 2006-06-05 20:24:10 +0200 | [diff] [blame^] | 265 | bcm43xx_lock_irqonly(bcm, flags); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 266 | |
| 267 | txctl = bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL); |
| 268 | if (txctl & BCM43xx_PIO_TXCTL_SUSPEND) |
| 269 | goto out_unlock; |
| 270 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 271 | list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) { |
| 272 | assert(packet->xmitted_frags < packet->txb->nr_frags); |
| 273 | if (packet->xmitted_frags == 0) { |
| 274 | int i; |
| 275 | struct sk_buff *skb; |
| 276 | |
| 277 | /* Check if the device queue is big |
| 278 | * enough for every fragment. If not, drop the |
| 279 | * whole packet. |
| 280 | */ |
| 281 | for (i = 0; i < packet->txb->nr_frags; i++) { |
| 282 | skb = packet->txb->fragments[i]; |
| 283 | if (unlikely(skb->len > queue->tx_devq_size)) { |
| 284 | dprintkl(KERN_ERR PFX "PIO TX device queue too small. " |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 285 | "Dropping packet.\n"); |
| 286 | free_txpacket(packet, 1); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 287 | goto next_packet; |
| 288 | } |
| 289 | } |
| 290 | } |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 291 | /* Try to transmit the packet. |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 292 | * This may not completely succeed. |
| 293 | */ |
| 294 | err = pio_tx_packet(packet); |
| 295 | if (err) |
| 296 | break; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 297 | next_packet: |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 298 | continue; |
| 299 | } |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 300 | out_unlock: |
Michael Buesch | 78ff56a | 2006-06-05 20:24:10 +0200 | [diff] [blame^] | 301 | bcm43xx_unlock_irqonly(bcm, flags); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static void setup_txqueues(struct bcm43xx_pioqueue *queue) |
| 305 | { |
| 306 | struct bcm43xx_pio_txpacket *packet; |
| 307 | int i; |
| 308 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 309 | queue->nr_txfree = BCM43xx_PIO_MAXTXPACKETS; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 310 | for (i = 0; i < BCM43xx_PIO_MAXTXPACKETS; i++) { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 311 | packet = &(queue->tx_packets_cache[i]); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 312 | |
| 313 | packet->queue = queue; |
| 314 | INIT_LIST_HEAD(&packet->list); |
| 315 | |
| 316 | list_add(&packet->list, &queue->txfree); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | static |
| 321 | struct bcm43xx_pioqueue * bcm43xx_setup_pioqueue(struct bcm43xx_private *bcm, |
| 322 | u16 pio_mmio_base) |
| 323 | { |
| 324 | struct bcm43xx_pioqueue *queue; |
| 325 | u32 value; |
| 326 | u16 qsize; |
| 327 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 328 | queue = kzalloc(sizeof(*queue), GFP_KERNEL); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 329 | if (!queue) |
| 330 | goto out; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 331 | |
| 332 | queue->bcm = bcm; |
| 333 | queue->mmio_base = pio_mmio_base; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 334 | queue->need_workarounds = (bcm->current_core->rev < 3); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 335 | |
| 336 | INIT_LIST_HEAD(&queue->txfree); |
| 337 | INIT_LIST_HEAD(&queue->txqueue); |
| 338 | INIT_LIST_HEAD(&queue->txrunning); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 339 | tasklet_init(&queue->txtask, tx_tasklet, |
| 340 | (unsigned long)queue); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 341 | |
| 342 | value = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 343 | value &= ~BCM43xx_SBF_XFER_REG_BYTESWAP; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 344 | bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value); |
| 345 | |
| 346 | qsize = bcm43xx_read16(bcm, queue->mmio_base + BCM43xx_PIO_TXQBUFSIZE); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 347 | if (qsize == 0) { |
| 348 | printk(KERN_ERR PFX "ERROR: This card does not support PIO " |
| 349 | "operation mode. Please use DMA mode " |
| 350 | "(module parameter pio=0).\n"); |
| 351 | goto err_freequeue; |
| 352 | } |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 353 | if (qsize <= BCM43xx_PIO_TXQADJUST) { |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 354 | printk(KERN_ERR PFX "PIO tx device-queue too small (%u)\n", |
| 355 | qsize); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 356 | goto err_freequeue; |
| 357 | } |
| 358 | qsize -= BCM43xx_PIO_TXQADJUST; |
| 359 | queue->tx_devq_size = qsize; |
| 360 | |
| 361 | setup_txqueues(queue); |
| 362 | |
| 363 | out: |
| 364 | return queue; |
| 365 | |
| 366 | err_freequeue: |
| 367 | kfree(queue); |
| 368 | queue = NULL; |
| 369 | goto out; |
| 370 | } |
| 371 | |
| 372 | static void cancel_transfers(struct bcm43xx_pioqueue *queue) |
| 373 | { |
| 374 | struct bcm43xx_pio_txpacket *packet, *tmp_packet; |
| 375 | |
| 376 | netif_tx_disable(queue->bcm->net_dev); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 377 | tasklet_disable(&queue->txtask); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 378 | |
| 379 | list_for_each_entry_safe(packet, tmp_packet, &queue->txrunning, list) |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 380 | free_txpacket(packet, 0); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 381 | list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 382 | free_txpacket(packet, 0); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | static void bcm43xx_destroy_pioqueue(struct bcm43xx_pioqueue *queue) |
| 386 | { |
| 387 | if (!queue) |
| 388 | return; |
| 389 | |
| 390 | cancel_transfers(queue); |
| 391 | kfree(queue); |
| 392 | } |
| 393 | |
| 394 | void bcm43xx_pio_free(struct bcm43xx_private *bcm) |
| 395 | { |
Michael Buesch | 49f29efa | 2006-03-14 16:05:26 +0100 | [diff] [blame] | 396 | struct bcm43xx_pio *pio; |
| 397 | |
| 398 | if (!bcm43xx_using_pio(bcm)) |
| 399 | return; |
| 400 | pio = bcm43xx_current_pio(bcm); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 401 | |
| 402 | bcm43xx_destroy_pioqueue(pio->queue3); |
| 403 | pio->queue3 = NULL; |
| 404 | bcm43xx_destroy_pioqueue(pio->queue2); |
| 405 | pio->queue2 = NULL; |
| 406 | bcm43xx_destroy_pioqueue(pio->queue1); |
| 407 | pio->queue1 = NULL; |
| 408 | bcm43xx_destroy_pioqueue(pio->queue0); |
| 409 | pio->queue0 = NULL; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | int bcm43xx_pio_init(struct bcm43xx_private *bcm) |
| 413 | { |
Michael Buesch | e9357c0 | 2006-03-13 19:27:34 +0100 | [diff] [blame] | 414 | struct bcm43xx_pio *pio = bcm43xx_current_pio(bcm); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 415 | struct bcm43xx_pioqueue *queue; |
| 416 | int err = -ENOMEM; |
| 417 | |
| 418 | queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO1_BASE); |
| 419 | if (!queue) |
| 420 | goto out; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 421 | pio->queue0 = queue; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 422 | |
| 423 | queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO2_BASE); |
| 424 | if (!queue) |
| 425 | goto err_destroy0; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 426 | pio->queue1 = queue; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 427 | |
| 428 | queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO3_BASE); |
| 429 | if (!queue) |
| 430 | goto err_destroy1; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 431 | pio->queue2 = queue; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 432 | |
| 433 | queue = bcm43xx_setup_pioqueue(bcm, BCM43xx_MMIO_PIO4_BASE); |
| 434 | if (!queue) |
| 435 | goto err_destroy2; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 436 | pio->queue3 = queue; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 437 | |
| 438 | if (bcm->current_core->rev < 3) |
| 439 | bcm->irq_savedstate |= BCM43xx_IRQ_PIO_WORKAROUND; |
| 440 | |
| 441 | dprintk(KERN_INFO PFX "PIO initialized\n"); |
| 442 | err = 0; |
| 443 | out: |
| 444 | return err; |
| 445 | |
| 446 | err_destroy2: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 447 | bcm43xx_destroy_pioqueue(pio->queue2); |
| 448 | pio->queue2 = NULL; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 449 | err_destroy1: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 450 | bcm43xx_destroy_pioqueue(pio->queue1); |
| 451 | pio->queue1 = NULL; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 452 | err_destroy0: |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 453 | bcm43xx_destroy_pioqueue(pio->queue0); |
| 454 | pio->queue0 = NULL; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 455 | goto out; |
| 456 | } |
| 457 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 458 | int bcm43xx_pio_tx(struct bcm43xx_private *bcm, |
| 459 | struct ieee80211_txb *txb) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 460 | { |
Michael Buesch | e9357c0 | 2006-03-13 19:27:34 +0100 | [diff] [blame] | 461 | struct bcm43xx_pioqueue *queue = bcm43xx_current_pio(bcm)->queue1; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 462 | struct bcm43xx_pio_txpacket *packet; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 463 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 464 | assert(!queue->tx_suspended); |
| 465 | assert(!list_empty(&queue->txfree)); |
| 466 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 467 | packet = list_entry(queue->txfree.next, struct bcm43xx_pio_txpacket, list); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 468 | packet->txb = txb; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 469 | packet->xmitted_frags = 0; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 470 | packet->xmitted_octets = 0; |
| 471 | list_move_tail(&packet->list, &queue->txqueue); |
| 472 | queue->nr_txfree--; |
| 473 | assert(queue->nr_txfree < BCM43xx_PIO_MAXTXPACKETS); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 474 | |
| 475 | /* Suspend TX, if we are out of packets in the "free" queue. */ |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 476 | if (list_empty(&queue->txfree)) { |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 477 | netif_stop_queue(queue->bcm->net_dev); |
| 478 | queue->tx_suspended = 1; |
| 479 | } |
| 480 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 481 | tasklet_schedule(&queue->txtask); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 482 | |
| 483 | return 0; |
| 484 | } |
| 485 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 486 | void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm, |
| 487 | struct bcm43xx_xmitstatus *status) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 488 | { |
| 489 | struct bcm43xx_pioqueue *queue; |
| 490 | struct bcm43xx_pio_txpacket *packet; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 491 | |
| 492 | queue = parse_cookie(bcm, status->cookie, &packet); |
| 493 | assert(queue); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 494 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 495 | free_txpacket(packet, 1); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 496 | if (queue->tx_suspended) { |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 497 | queue->tx_suspended = 0; |
| 498 | netif_wake_queue(queue->bcm->net_dev); |
| 499 | } |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 500 | /* If there are packets on the txqueue, poke the tasklet |
| 501 | * to transmit them. |
| 502 | */ |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 503 | if (!list_empty(&queue->txqueue)) |
| 504 | tasklet_schedule(&queue->txtask); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | static void pio_rx_error(struct bcm43xx_pioqueue *queue, |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 508 | int clear_buffers, |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 509 | const char *error) |
| 510 | { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 511 | int i; |
| 512 | |
| 513 | printkl("PIO RX error: %s\n", error); |
| 514 | bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL, |
| 515 | BCM43xx_PIO_RXCTL_READY); |
| 516 | if (clear_buffers) { |
| 517 | assert(queue->mmio_base == BCM43xx_MMIO_PIO1_BASE); |
| 518 | for (i = 0; i < 15; i++) { |
| 519 | /* Dummy read. */ |
| 520 | bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
| 521 | } |
| 522 | } |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 523 | } |
| 524 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 525 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 526 | { |
| 527 | u16 preamble[21] = { 0 }; |
| 528 | struct bcm43xx_rxhdr *rxhdr; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 529 | u16 tmp, len, rxflags2; |
| 530 | int i, preamble_readwords; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 531 | struct sk_buff *skb; |
| 532 | |
| 533 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXCTL); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 534 | if (!(tmp & BCM43xx_PIO_RXCTL_DATAAVAILABLE)) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 535 | return; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 536 | bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL, |
| 537 | BCM43xx_PIO_RXCTL_DATAAVAILABLE); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 538 | |
| 539 | for (i = 0; i < 10; i++) { |
| 540 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXCTL); |
| 541 | if (tmp & BCM43xx_PIO_RXCTL_READY) |
| 542 | goto data_ready; |
| 543 | udelay(10); |
| 544 | } |
| 545 | dprintkl(KERN_ERR PFX "PIO RX timed out\n"); |
| 546 | return; |
| 547 | data_ready: |
| 548 | |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 549 | len = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 550 | if (unlikely(len > 0x700)) { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 551 | pio_rx_error(queue, 0, "len > 0x700"); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 552 | return; |
| 553 | } |
| 554 | if (unlikely(len == 0 && queue->mmio_base != BCM43xx_MMIO_PIO4_BASE)) { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 555 | pio_rx_error(queue, 0, "len == 0"); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 556 | return; |
| 557 | } |
| 558 | preamble[0] = cpu_to_le16(len); |
| 559 | if (queue->mmio_base == BCM43xx_MMIO_PIO4_BASE) |
| 560 | preamble_readwords = 14 / sizeof(u16); |
| 561 | else |
| 562 | preamble_readwords = 18 / sizeof(u16); |
| 563 | for (i = 0; i < preamble_readwords; i++) { |
| 564 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 565 | preamble[i + 1] = cpu_to_le16(tmp); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 566 | } |
| 567 | rxhdr = (struct bcm43xx_rxhdr *)preamble; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 568 | rxflags2 = le16_to_cpu(rxhdr->flags2); |
| 569 | if (unlikely(rxflags2 & BCM43xx_RXHDR_FLAGS2_INVALIDFRAME)) { |
| 570 | pio_rx_error(queue, |
| 571 | (queue->mmio_base == BCM43xx_MMIO_PIO1_BASE), |
| 572 | "invalid frame"); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 573 | return; |
| 574 | } |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 575 | if (queue->mmio_base == BCM43xx_MMIO_PIO4_BASE) { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 576 | /* We received an xmit status. */ |
| 577 | struct bcm43xx_hwxmitstatus *hw; |
| 578 | struct bcm43xx_xmitstatus stat; |
| 579 | |
| 580 | hw = (struct bcm43xx_hwxmitstatus *)(preamble + 1); |
| 581 | stat.cookie = le16_to_cpu(hw->cookie); |
| 582 | stat.flags = hw->flags; |
| 583 | stat.cnt1 = hw->cnt1; |
| 584 | stat.cnt2 = hw->cnt2; |
| 585 | stat.seq = le16_to_cpu(hw->seq); |
| 586 | stat.unknown = le16_to_cpu(hw->unknown); |
| 587 | |
| 588 | bcm43xx_debugfs_log_txstat(queue->bcm, &stat); |
| 589 | bcm43xx_pio_handle_xmitstatus(queue->bcm, &stat); |
| 590 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 591 | return; |
| 592 | } |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 593 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 594 | skb = dev_alloc_skb(len); |
| 595 | if (unlikely(!skb)) { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 596 | pio_rx_error(queue, 1, "OOM"); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 597 | return; |
| 598 | } |
| 599 | skb_put(skb, len); |
| 600 | for (i = 0; i < len - 1; i += 2) { |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 601 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
| 602 | *((u16 *)(skb->data + i)) = cpu_to_le16(tmp); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 603 | } |
| 604 | if (len % 2) { |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 605 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 606 | skb->data[len - 1] = (tmp & 0x00FF); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 607 | /* The specs say the following is required, but |
| 608 | * it is wrong and corrupts the PLCP. If we don't do |
| 609 | * this, the PLCP seems to be correct. So ifdef it out for now. |
| 610 | */ |
| 611 | #if 0 |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 612 | if (rxflags2 & BCM43xx_RXHDR_FLAGS2_TYPE2FRAME) |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 613 | skb->data[2] = (tmp & 0xFF00) >> 8; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 614 | else |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 615 | skb->data[0] = (tmp & 0xFF00) >> 8; |
| 616 | #endif |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 617 | } |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 618 | skb_trim(skb, len - IEEE80211_FCS_LEN); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 619 | bcm43xx_rx(queue->bcm, skb, rxhdr); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 620 | } |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 621 | |
| 622 | void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue) |
| 623 | { |
| 624 | bcm43xx_power_saving_ctl_bits(queue->bcm, -1, 1); |
| 625 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
| 626 | bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL) |
| 627 | | BCM43xx_PIO_TXCTL_SUSPEND); |
| 628 | } |
| 629 | |
| 630 | void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue) |
| 631 | { |
| 632 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
| 633 | bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL) |
| 634 | & ~BCM43xx_PIO_TXCTL_SUSPEND); |
| 635 | bcm43xx_power_saving_ctl_bits(queue->bcm, -1, -1); |
| 636 | tasklet_schedule(&queue->txtask); |
| 637 | } |