Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006-2007 PA Semi, Inc |
| 3 | * |
| 4 | * Driver for the PA Semi PWRficient onchip 1G/10G Ethernet MACs |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/pci.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/dmaengine.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/netdevice.h> |
| 27 | #include <linux/etherdevice.h> |
| 28 | #include <asm/dma-mapping.h> |
| 29 | #include <linux/in.h> |
| 30 | #include <linux/skbuff.h> |
| 31 | |
| 32 | #include <linux/ip.h> |
| 33 | #include <linux/tcp.h> |
| 34 | #include <net/checksum.h> |
| 35 | |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 36 | #include <asm/irq.h> |
| 37 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 38 | #include "pasemi_mac.h" |
| 39 | |
| 40 | |
| 41 | /* TODO list |
| 42 | * |
| 43 | * - Get rid of pci_{read,write}_config(), map registers with ioremap |
| 44 | * for performance |
| 45 | * - PHY support |
| 46 | * - Multicast support |
| 47 | * - Large MTU support |
| 48 | * - Other performance improvements |
| 49 | */ |
| 50 | |
| 51 | |
| 52 | /* Must be a power of two */ |
| 53 | #define RX_RING_SIZE 512 |
| 54 | #define TX_RING_SIZE 512 |
| 55 | |
Olof Johansson | ceb5136 | 2007-05-08 00:47:49 -0500 | [diff] [blame] | 56 | #define DEFAULT_MSG_ENABLE \ |
| 57 | (NETIF_MSG_DRV | \ |
| 58 | NETIF_MSG_PROBE | \ |
| 59 | NETIF_MSG_LINK | \ |
| 60 | NETIF_MSG_TIMER | \ |
| 61 | NETIF_MSG_IFDOWN | \ |
| 62 | NETIF_MSG_IFUP | \ |
| 63 | NETIF_MSG_RX_ERR | \ |
| 64 | NETIF_MSG_TX_ERR) |
| 65 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 66 | #define TX_DESC(mac, num) ((mac)->tx->desc[(num) & (TX_RING_SIZE-1)]) |
| 67 | #define TX_DESC_INFO(mac, num) ((mac)->tx->desc_info[(num) & (TX_RING_SIZE-1)]) |
| 68 | #define RX_DESC(mac, num) ((mac)->rx->desc[(num) & (RX_RING_SIZE-1)]) |
| 69 | #define RX_DESC_INFO(mac, num) ((mac)->rx->desc_info[(num) & (RX_RING_SIZE-1)]) |
| 70 | #define RX_BUFF(mac, num) ((mac)->rx->buffers[(num) & (RX_RING_SIZE-1)]) |
| 71 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 72 | #define RING_USED(ring) (((ring)->next_to_fill - (ring)->next_to_clean) \ |
| 73 | & ((ring)->size - 1)) |
| 74 | #define RING_AVAIL(ring) ((ring->size) - RING_USED(ring)) |
| 75 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 76 | #define BUF_SIZE 1646 /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */ |
| 77 | |
Olof Johansson | ceb5136 | 2007-05-08 00:47:49 -0500 | [diff] [blame] | 78 | MODULE_LICENSE("GPL"); |
| 79 | MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>"); |
| 80 | MODULE_DESCRIPTION("PA Semi PWRficient Ethernet driver"); |
| 81 | |
| 82 | static int debug = -1; /* -1 == use DEFAULT_MSG_ENABLE as value */ |
| 83 | module_param(debug, int, 0); |
| 84 | MODULE_PARM_DESC(debug, "PA Semi MAC bitmapped debugging message enable value"); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 85 | |
| 86 | static struct pasdma_status *dma_status; |
| 87 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 88 | static void write_iob_reg(struct pasemi_mac *mac, unsigned int reg, |
| 89 | unsigned int val) |
| 90 | { |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 91 | out_le32(mac->iob_regs+reg, val); |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static unsigned int read_mac_reg(struct pasemi_mac *mac, unsigned int reg) |
| 95 | { |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 96 | return in_le32(mac->regs+reg); |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static void write_mac_reg(struct pasemi_mac *mac, unsigned int reg, |
| 100 | unsigned int val) |
| 101 | { |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 102 | out_le32(mac->regs+reg, val); |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | static unsigned int read_dma_reg(struct pasemi_mac *mac, unsigned int reg) |
| 106 | { |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 107 | return in_le32(mac->dma_regs+reg); |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | static void write_dma_reg(struct pasemi_mac *mac, unsigned int reg, |
| 111 | unsigned int val) |
| 112 | { |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 113 | out_le32(mac->dma_regs+reg, val); |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 116 | static int pasemi_get_mac_addr(struct pasemi_mac *mac) |
| 117 | { |
| 118 | struct pci_dev *pdev = mac->pdev; |
| 119 | struct device_node *dn = pci_device_to_OF_node(pdev); |
olof@lixom.net | 1af7f05 | 2007-05-12 14:57:46 -0500 | [diff] [blame] | 120 | int len; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 121 | const u8 *maddr; |
| 122 | u8 addr[6]; |
| 123 | |
| 124 | if (!dn) { |
| 125 | dev_dbg(&pdev->dev, |
| 126 | "No device node for mac, not configuring\n"); |
| 127 | return -ENOENT; |
| 128 | } |
| 129 | |
olof@lixom.net | 1af7f05 | 2007-05-12 14:57:46 -0500 | [diff] [blame] | 130 | maddr = of_get_property(dn, "local-mac-address", &len); |
Olof Johansson | a5fd22e | 2007-05-08 00:48:02 -0500 | [diff] [blame] | 131 | |
olof@lixom.net | 1af7f05 | 2007-05-12 14:57:46 -0500 | [diff] [blame] | 132 | if (maddr && len == 6) { |
| 133 | memcpy(mac->mac_addr, maddr, 6); |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | /* Some old versions of firmware mistakenly uses mac-address |
| 138 | * (and as a string) instead of a byte array in local-mac-address. |
| 139 | */ |
| 140 | |
Olof Johansson | a5fd22e | 2007-05-08 00:48:02 -0500 | [diff] [blame] | 141 | if (maddr == NULL) |
Linus Torvalds | 9028780 | 2007-05-08 11:57:17 -0700 | [diff] [blame] | 142 | maddr = of_get_property(dn, "mac-address", NULL); |
Olof Johansson | a5fd22e | 2007-05-08 00:48:02 -0500 | [diff] [blame] | 143 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 144 | if (maddr == NULL) { |
| 145 | dev_warn(&pdev->dev, |
| 146 | "no mac address in device tree, not configuring\n"); |
| 147 | return -ENOENT; |
| 148 | } |
| 149 | |
olof@lixom.net | 1af7f05 | 2007-05-12 14:57:46 -0500 | [diff] [blame] | 150 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 151 | if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[0], |
| 152 | &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) { |
| 153 | dev_warn(&pdev->dev, |
| 154 | "can't parse mac address, not configuring\n"); |
| 155 | return -EINVAL; |
| 156 | } |
| 157 | |
olof@lixom.net | 1af7f05 | 2007-05-12 14:57:46 -0500 | [diff] [blame] | 158 | memcpy(mac->mac_addr, addr, 6); |
| 159 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | static int pasemi_mac_setup_rx_resources(struct net_device *dev) |
| 164 | { |
| 165 | struct pasemi_mac_rxring *ring; |
| 166 | struct pasemi_mac *mac = netdev_priv(dev); |
| 167 | int chan_id = mac->dma_rxch; |
| 168 | |
| 169 | ring = kzalloc(sizeof(*ring), GFP_KERNEL); |
| 170 | |
| 171 | if (!ring) |
| 172 | goto out_ring; |
| 173 | |
| 174 | spin_lock_init(&ring->lock); |
| 175 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 176 | ring->size = RX_RING_SIZE; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 177 | ring->desc_info = kzalloc(sizeof(struct pasemi_mac_buffer) * |
| 178 | RX_RING_SIZE, GFP_KERNEL); |
| 179 | |
| 180 | if (!ring->desc_info) |
| 181 | goto out_desc_info; |
| 182 | |
| 183 | /* Allocate descriptors */ |
| 184 | ring->desc = dma_alloc_coherent(&mac->dma_pdev->dev, |
| 185 | RX_RING_SIZE * |
| 186 | sizeof(struct pas_dma_xct_descr), |
| 187 | &ring->dma, GFP_KERNEL); |
| 188 | |
| 189 | if (!ring->desc) |
| 190 | goto out_desc; |
| 191 | |
| 192 | memset(ring->desc, 0, RX_RING_SIZE * sizeof(struct pas_dma_xct_descr)); |
| 193 | |
| 194 | ring->buffers = dma_alloc_coherent(&mac->dma_pdev->dev, |
| 195 | RX_RING_SIZE * sizeof(u64), |
| 196 | &ring->buf_dma, GFP_KERNEL); |
| 197 | if (!ring->buffers) |
| 198 | goto out_buffers; |
| 199 | |
| 200 | memset(ring->buffers, 0, RX_RING_SIZE * sizeof(u64)); |
| 201 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 202 | write_dma_reg(mac, PAS_DMA_RXCHAN_BASEL(chan_id), PAS_DMA_RXCHAN_BASEL_BRBL(ring->dma)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 203 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 204 | write_dma_reg(mac, PAS_DMA_RXCHAN_BASEU(chan_id), |
| 205 | PAS_DMA_RXCHAN_BASEU_BRBH(ring->dma >> 32) | |
| 206 | PAS_DMA_RXCHAN_BASEU_SIZ(RX_RING_SIZE >> 2)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 207 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 208 | write_dma_reg(mac, PAS_DMA_RXCHAN_CFG(chan_id), |
Olof Johansson | c0efd52 | 2007-08-22 09:12:52 -0500 | [diff] [blame] | 209 | PAS_DMA_RXCHAN_CFG_HBU(2)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 210 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 211 | write_dma_reg(mac, PAS_DMA_RXINT_BASEL(mac->dma_if), |
| 212 | PAS_DMA_RXINT_BASEL_BRBL(__pa(ring->buffers))); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 213 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 214 | write_dma_reg(mac, PAS_DMA_RXINT_BASEU(mac->dma_if), |
| 215 | PAS_DMA_RXINT_BASEU_BRBH(__pa(ring->buffers) >> 32) | |
| 216 | PAS_DMA_RXINT_BASEU_SIZ(RX_RING_SIZE >> 3)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 217 | |
Olof Johansson | c0efd52 | 2007-08-22 09:12:52 -0500 | [diff] [blame] | 218 | write_dma_reg(mac, PAS_DMA_RXINT_CFG(mac->dma_if), |
| 219 | PAS_DMA_RXINT_CFG_DHL(2)); |
| 220 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 221 | ring->next_to_fill = 0; |
| 222 | ring->next_to_clean = 0; |
| 223 | |
| 224 | snprintf(ring->irq_name, sizeof(ring->irq_name), |
| 225 | "%s rx", dev->name); |
| 226 | mac->rx = ring; |
| 227 | |
| 228 | return 0; |
| 229 | |
| 230 | out_buffers: |
| 231 | dma_free_coherent(&mac->dma_pdev->dev, |
| 232 | RX_RING_SIZE * sizeof(struct pas_dma_xct_descr), |
| 233 | mac->rx->desc, mac->rx->dma); |
| 234 | out_desc: |
| 235 | kfree(ring->desc_info); |
| 236 | out_desc_info: |
| 237 | kfree(ring); |
| 238 | out_ring: |
| 239 | return -ENOMEM; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | static int pasemi_mac_setup_tx_resources(struct net_device *dev) |
| 244 | { |
| 245 | struct pasemi_mac *mac = netdev_priv(dev); |
| 246 | u32 val; |
| 247 | int chan_id = mac->dma_txch; |
| 248 | struct pasemi_mac_txring *ring; |
| 249 | |
| 250 | ring = kzalloc(sizeof(*ring), GFP_KERNEL); |
| 251 | if (!ring) |
| 252 | goto out_ring; |
| 253 | |
| 254 | spin_lock_init(&ring->lock); |
| 255 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 256 | ring->size = TX_RING_SIZE; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 257 | ring->desc_info = kzalloc(sizeof(struct pasemi_mac_buffer) * |
| 258 | TX_RING_SIZE, GFP_KERNEL); |
| 259 | if (!ring->desc_info) |
| 260 | goto out_desc_info; |
| 261 | |
| 262 | /* Allocate descriptors */ |
| 263 | ring->desc = dma_alloc_coherent(&mac->dma_pdev->dev, |
| 264 | TX_RING_SIZE * |
| 265 | sizeof(struct pas_dma_xct_descr), |
| 266 | &ring->dma, GFP_KERNEL); |
| 267 | if (!ring->desc) |
| 268 | goto out_desc; |
| 269 | |
| 270 | memset(ring->desc, 0, TX_RING_SIZE * sizeof(struct pas_dma_xct_descr)); |
| 271 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 272 | write_dma_reg(mac, PAS_DMA_TXCHAN_BASEL(chan_id), |
| 273 | PAS_DMA_TXCHAN_BASEL_BRBL(ring->dma)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 274 | val = PAS_DMA_TXCHAN_BASEU_BRBH(ring->dma >> 32); |
| 275 | val |= PAS_DMA_TXCHAN_BASEU_SIZ(TX_RING_SIZE >> 2); |
| 276 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 277 | write_dma_reg(mac, PAS_DMA_TXCHAN_BASEU(chan_id), val); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 278 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 279 | write_dma_reg(mac, PAS_DMA_TXCHAN_CFG(chan_id), |
| 280 | PAS_DMA_TXCHAN_CFG_TY_IFACE | |
| 281 | PAS_DMA_TXCHAN_CFG_TATTR(mac->dma_if) | |
| 282 | PAS_DMA_TXCHAN_CFG_UP | |
| 283 | PAS_DMA_TXCHAN_CFG_WT(2)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 284 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 285 | ring->next_to_fill = 0; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 286 | ring->next_to_clean = 0; |
| 287 | |
| 288 | snprintf(ring->irq_name, sizeof(ring->irq_name), |
| 289 | "%s tx", dev->name); |
| 290 | mac->tx = ring; |
| 291 | |
| 292 | return 0; |
| 293 | |
| 294 | out_desc: |
| 295 | kfree(ring->desc_info); |
| 296 | out_desc_info: |
| 297 | kfree(ring); |
| 298 | out_ring: |
| 299 | return -ENOMEM; |
| 300 | } |
| 301 | |
| 302 | static void pasemi_mac_free_tx_resources(struct net_device *dev) |
| 303 | { |
| 304 | struct pasemi_mac *mac = netdev_priv(dev); |
| 305 | unsigned int i; |
| 306 | struct pasemi_mac_buffer *info; |
| 307 | struct pas_dma_xct_descr *dp; |
| 308 | |
| 309 | for (i = 0; i < TX_RING_SIZE; i++) { |
| 310 | info = &TX_DESC_INFO(mac, i); |
| 311 | dp = &TX_DESC(mac, i); |
| 312 | if (info->dma) { |
| 313 | if (info->skb) { |
| 314 | pci_unmap_single(mac->dma_pdev, |
| 315 | info->dma, |
| 316 | info->skb->len, |
| 317 | PCI_DMA_TODEVICE); |
| 318 | dev_kfree_skb_any(info->skb); |
| 319 | } |
| 320 | info->dma = 0; |
| 321 | info->skb = NULL; |
| 322 | dp->mactx = 0; |
| 323 | dp->ptr = 0; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | dma_free_coherent(&mac->dma_pdev->dev, |
| 328 | TX_RING_SIZE * sizeof(struct pas_dma_xct_descr), |
| 329 | mac->tx->desc, mac->tx->dma); |
| 330 | |
| 331 | kfree(mac->tx->desc_info); |
| 332 | kfree(mac->tx); |
| 333 | mac->tx = NULL; |
| 334 | } |
| 335 | |
| 336 | static void pasemi_mac_free_rx_resources(struct net_device *dev) |
| 337 | { |
| 338 | struct pasemi_mac *mac = netdev_priv(dev); |
| 339 | unsigned int i; |
| 340 | struct pasemi_mac_buffer *info; |
| 341 | struct pas_dma_xct_descr *dp; |
| 342 | |
| 343 | for (i = 0; i < RX_RING_SIZE; i++) { |
| 344 | info = &RX_DESC_INFO(mac, i); |
| 345 | dp = &RX_DESC(mac, i); |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 346 | if (info->skb) { |
| 347 | if (info->dma) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 348 | pci_unmap_single(mac->dma_pdev, |
| 349 | info->dma, |
| 350 | info->skb->len, |
| 351 | PCI_DMA_FROMDEVICE); |
| 352 | dev_kfree_skb_any(info->skb); |
| 353 | } |
| 354 | info->dma = 0; |
| 355 | info->skb = NULL; |
| 356 | dp->macrx = 0; |
| 357 | dp->ptr = 0; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | dma_free_coherent(&mac->dma_pdev->dev, |
| 362 | RX_RING_SIZE * sizeof(struct pas_dma_xct_descr), |
| 363 | mac->rx->desc, mac->rx->dma); |
| 364 | |
| 365 | dma_free_coherent(&mac->dma_pdev->dev, RX_RING_SIZE * sizeof(u64), |
| 366 | mac->rx->buffers, mac->rx->buf_dma); |
| 367 | |
| 368 | kfree(mac->rx->desc_info); |
| 369 | kfree(mac->rx); |
| 370 | mac->rx = NULL; |
| 371 | } |
| 372 | |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 373 | static void pasemi_mac_replenish_rx_ring(struct net_device *dev, int limit) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 374 | { |
| 375 | struct pasemi_mac *mac = netdev_priv(dev); |
| 376 | unsigned int i; |
| 377 | int start = mac->rx->next_to_fill; |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 378 | int count; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 379 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 380 | if (limit <= 0) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 381 | return; |
| 382 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 383 | i = start; |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 384 | for (count = 0; count < limit; count++) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 385 | struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i); |
| 386 | u64 *buff = &RX_BUFF(mac, i); |
| 387 | struct sk_buff *skb; |
| 388 | dma_addr_t dma; |
| 389 | |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 390 | /* skb might still be in there for recycle on short receives */ |
| 391 | if (info->skb) |
| 392 | skb = info->skb; |
| 393 | else |
| 394 | skb = dev_alloc_skb(BUF_SIZE); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 395 | |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 396 | if (unlikely(!skb)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 397 | break; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 398 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 399 | dma = pci_map_single(mac->dma_pdev, skb->data, skb->len, |
| 400 | PCI_DMA_FROMDEVICE); |
| 401 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 402 | if (unlikely(dma_mapping_error(dma))) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 403 | dev_kfree_skb_irq(info->skb); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 404 | break; |
| 405 | } |
| 406 | |
| 407 | info->skb = skb; |
| 408 | info->dma = dma; |
| 409 | *buff = XCT_RXB_LEN(BUF_SIZE) | XCT_RXB_ADDR(dma); |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 410 | i++; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | wmb(); |
| 414 | |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 415 | write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), count); |
| 416 | write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), count); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 417 | |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 418 | mac->rx->next_to_fill += count; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 419 | } |
| 420 | |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 421 | static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac) |
| 422 | { |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 423 | unsigned int reg, pcnt; |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 424 | /* Re-enable packet count interrupts: finally |
| 425 | * ack the packet count interrupt we got in rx_intr. |
| 426 | */ |
| 427 | |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 428 | pcnt = *mac->rx_status & PAS_STATUS_PCNT_M; |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 429 | |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 430 | reg = PAS_IOB_DMA_RXCH_RESET_PCNT(pcnt) | PAS_IOB_DMA_RXCH_RESET_PINTC; |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 431 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 432 | write_iob_reg(mac, PAS_IOB_DMA_RXCH_RESET(mac->dma_rxch), reg); |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | static void pasemi_mac_restart_tx_intr(struct pasemi_mac *mac) |
| 436 | { |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 437 | unsigned int reg, pcnt; |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 438 | |
| 439 | /* Re-enable packet count interrupts */ |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 440 | pcnt = *mac->tx_status & PAS_STATUS_PCNT_M; |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 441 | |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 442 | reg = PAS_IOB_DMA_TXCH_RESET_PCNT(pcnt) | PAS_IOB_DMA_TXCH_RESET_PINTC; |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 443 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 444 | write_iob_reg(mac, PAS_IOB_DMA_TXCH_RESET(mac->dma_txch), reg); |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 448 | static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit) |
| 449 | { |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 450 | unsigned int n; |
| 451 | int count; |
| 452 | struct pas_dma_xct_descr *dp; |
| 453 | struct pasemi_mac_buffer *info; |
| 454 | struct sk_buff *skb; |
| 455 | unsigned int i, len; |
| 456 | u64 macrx; |
| 457 | dma_addr_t dma; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 458 | |
| 459 | spin_lock(&mac->rx->lock); |
| 460 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 461 | n = mac->rx->next_to_clean; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 462 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 463 | for (count = limit; count; count--) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 464 | |
| 465 | rmb(); |
| 466 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 467 | dp = &RX_DESC(mac, n); |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 468 | prefetchw(dp); |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 469 | macrx = dp->macrx; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 470 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 471 | if (!(macrx & XCT_MACRX_O)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 472 | break; |
| 473 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 474 | |
| 475 | info = NULL; |
| 476 | |
| 477 | /* We have to scan for our skb since there's no way |
| 478 | * to back-map them from the descriptor, and if we |
| 479 | * have several receive channels then they might not |
| 480 | * show up in the same order as they were put on the |
| 481 | * interface ring. |
| 482 | */ |
| 483 | |
| 484 | dma = (dp->ptr & XCT_PTR_ADDR_M); |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 485 | for (i = n; i < (n + RX_RING_SIZE); i++) { |
| 486 | info = &RX_DESC_INFO(mac, i); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 487 | if (info->dma == dma) |
| 488 | break; |
| 489 | } |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 490 | prefetchw(info); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 491 | |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 492 | skb = info->skb; |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 493 | prefetchw(skb); |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 494 | info->dma = 0; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 495 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 496 | pci_unmap_single(mac->dma_pdev, dma, skb->len, |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 497 | PCI_DMA_FROMDEVICE); |
| 498 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 499 | len = (macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 500 | |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 501 | if (len < 256) { |
| 502 | struct sk_buff *new_skb = |
| 503 | netdev_alloc_skb(mac->netdev, len + NET_IP_ALIGN); |
| 504 | if (new_skb) { |
| 505 | skb_reserve(new_skb, NET_IP_ALIGN); |
Olof Johansson | 7334486 | 2007-08-22 09:12:55 -0500 | [diff] [blame] | 506 | memcpy(new_skb->data, skb->data, len); |
Olof Johansson | 9f05cfe | 2007-05-08 00:47:37 -0500 | [diff] [blame] | 507 | /* save the skb in buffer_info as good */ |
| 508 | skb = new_skb; |
| 509 | } |
| 510 | /* else just continue with the old one */ |
| 511 | } else |
| 512 | info->skb = NULL; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 513 | |
| 514 | skb_put(skb, len); |
| 515 | |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 516 | if (likely((macrx & XCT_MACRX_HTY_M) == XCT_MACRX_HTY_IPV4_OK)) { |
Olof Johansson | 38bf318 | 2007-08-22 09:13:24 -0500 | [diff] [blame] | 517 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 518 | skb->csum = (macrx & XCT_MACRX_CSUM_M) >> |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 519 | XCT_MACRX_CSUM_S; |
| 520 | } else |
| 521 | skb->ip_summed = CHECKSUM_NONE; |
| 522 | |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 523 | mac->netdev->stats.rx_bytes += len; |
| 524 | mac->netdev->stats.rx_packets++; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 525 | |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 526 | skb->protocol = eth_type_trans(skb, mac->netdev); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 527 | netif_receive_skb(skb); |
| 528 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 529 | dp->ptr = 0; |
| 530 | dp->macrx = 0; |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 531 | |
| 532 | n++; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 533 | } |
| 534 | |
Olof Johansson | cd4ceb2 | 2007-05-08 00:47:45 -0500 | [diff] [blame] | 535 | mac->rx->next_to_clean += limit - count; |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 536 | pasemi_mac_replenish_rx_ring(mac->netdev, limit-count); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 537 | |
| 538 | spin_unlock(&mac->rx->lock); |
| 539 | |
| 540 | return count; |
| 541 | } |
| 542 | |
| 543 | static int pasemi_mac_clean_tx(struct pasemi_mac *mac) |
| 544 | { |
| 545 | int i; |
| 546 | struct pasemi_mac_buffer *info; |
| 547 | struct pas_dma_xct_descr *dp; |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 548 | unsigned int start, count, limit; |
| 549 | unsigned int total_count; |
Olof Johansson | ca7e235 | 2007-09-26 16:23:59 -0500 | [diff] [blame] | 550 | unsigned long flags; |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 551 | struct sk_buff *skbs[32]; |
| 552 | dma_addr_t dmas[32]; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 553 | |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 554 | total_count = 0; |
| 555 | restart: |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 556 | spin_lock_irqsave(&mac->tx->lock, flags); |
| 557 | |
| 558 | start = mac->tx->next_to_clean; |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 559 | limit = min(mac->tx->next_to_fill, start+32); |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 560 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 561 | count = 0; |
| 562 | |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 563 | for (i = start; i < limit; i++) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 564 | dp = &TX_DESC(mac, i); |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 565 | |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 566 | if (unlikely(dp->mactx & XCT_MACTX_O)) |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 567 | /* Not yet transmitted */ |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 568 | break; |
| 569 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 570 | info = &TX_DESC_INFO(mac, i); |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 571 | skbs[count] = info->skb; |
| 572 | dmas[count] = info->dma; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 573 | |
| 574 | info->skb = NULL; |
| 575 | info->dma = 0; |
| 576 | dp->mactx = 0; |
| 577 | dp->ptr = 0; |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 578 | |
| 579 | count++; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 580 | } |
| 581 | mac->tx->next_to_clean += count; |
| 582 | spin_unlock_irqrestore(&mac->tx->lock, flags); |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 583 | netif_wake_queue(mac->netdev); |
| 584 | |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 585 | for (i = 0; i < count; i++) { |
| 586 | pci_unmap_single(mac->dma_pdev, dmas[i], |
| 587 | skbs[i]->len, PCI_DMA_TODEVICE); |
| 588 | dev_kfree_skb_irq(skbs[i]); |
| 589 | } |
| 590 | |
| 591 | total_count += count; |
| 592 | |
| 593 | /* If the batch was full, try to clean more */ |
| 594 | if (count == 32) |
| 595 | goto restart; |
| 596 | |
| 597 | return total_count; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | |
| 601 | static irqreturn_t pasemi_mac_rx_intr(int irq, void *data) |
| 602 | { |
| 603 | struct net_device *dev = data; |
| 604 | struct pasemi_mac *mac = netdev_priv(dev); |
| 605 | unsigned int reg; |
| 606 | |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 607 | if (!(*mac->rx_status & PAS_STATUS_CAUSE_M)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 608 | return IRQ_NONE; |
| 609 | |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 610 | if (*mac->rx_status & PAS_STATUS_ERROR) |
| 611 | printk("rx_status reported error\n"); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 612 | |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 613 | /* Don't reset packet count so it won't fire again but clear |
| 614 | * all others. |
| 615 | */ |
| 616 | |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 617 | reg = 0; |
| 618 | if (*mac->rx_status & PAS_STATUS_SOFT) |
| 619 | reg |= PAS_IOB_DMA_RXCH_RESET_SINTC; |
| 620 | if (*mac->rx_status & PAS_STATUS_ERROR) |
| 621 | reg |= PAS_IOB_DMA_RXCH_RESET_DINTC; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 622 | if (*mac->rx_status & PAS_STATUS_TIMER) |
| 623 | reg |= PAS_IOB_DMA_RXCH_RESET_TINTC; |
| 624 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 625 | netif_rx_schedule(dev, &mac->napi); |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 626 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 627 | write_iob_reg(mac, PAS_IOB_DMA_RXCH_RESET(mac->dma_rxch), reg); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 628 | |
| 629 | return IRQ_HANDLED; |
| 630 | } |
| 631 | |
| 632 | static irqreturn_t pasemi_mac_tx_intr(int irq, void *data) |
| 633 | { |
| 634 | struct net_device *dev = data; |
| 635 | struct pasemi_mac *mac = netdev_priv(dev); |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 636 | unsigned int reg, pcnt; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 637 | |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 638 | if (!(*mac->tx_status & PAS_STATUS_CAUSE_M)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 639 | return IRQ_NONE; |
| 640 | |
| 641 | pasemi_mac_clean_tx(mac); |
| 642 | |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 643 | pcnt = *mac->tx_status & PAS_STATUS_PCNT_M; |
| 644 | |
| 645 | reg = PAS_IOB_DMA_TXCH_RESET_PCNT(pcnt) | PAS_IOB_DMA_TXCH_RESET_PINTC; |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 646 | |
| 647 | if (*mac->tx_status & PAS_STATUS_SOFT) |
| 648 | reg |= PAS_IOB_DMA_TXCH_RESET_SINTC; |
| 649 | if (*mac->tx_status & PAS_STATUS_ERROR) |
| 650 | reg |= PAS_IOB_DMA_TXCH_RESET_DINTC; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 651 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 652 | write_iob_reg(mac, PAS_IOB_DMA_TXCH_RESET(mac->dma_txch), reg); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 653 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 654 | return IRQ_HANDLED; |
| 655 | } |
| 656 | |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 657 | static void pasemi_adjust_link(struct net_device *dev) |
| 658 | { |
| 659 | struct pasemi_mac *mac = netdev_priv(dev); |
| 660 | int msg; |
| 661 | unsigned int flags; |
| 662 | unsigned int new_flags; |
| 663 | |
| 664 | if (!mac->phydev->link) { |
| 665 | /* If no link, MAC speed settings don't matter. Just report |
| 666 | * link down and return. |
| 667 | */ |
| 668 | if (mac->link && netif_msg_link(mac)) |
| 669 | printk(KERN_INFO "%s: Link is down.\n", dev->name); |
| 670 | |
| 671 | netif_carrier_off(dev); |
| 672 | mac->link = 0; |
| 673 | |
| 674 | return; |
| 675 | } else |
| 676 | netif_carrier_on(dev); |
| 677 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 678 | flags = read_mac_reg(mac, PAS_MAC_CFG_PCFG); |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 679 | new_flags = flags & ~(PAS_MAC_CFG_PCFG_HD | PAS_MAC_CFG_PCFG_SPD_M | |
| 680 | PAS_MAC_CFG_PCFG_TSR_M); |
| 681 | |
| 682 | if (!mac->phydev->duplex) |
| 683 | new_flags |= PAS_MAC_CFG_PCFG_HD; |
| 684 | |
| 685 | switch (mac->phydev->speed) { |
| 686 | case 1000: |
| 687 | new_flags |= PAS_MAC_CFG_PCFG_SPD_1G | |
| 688 | PAS_MAC_CFG_PCFG_TSR_1G; |
| 689 | break; |
| 690 | case 100: |
| 691 | new_flags |= PAS_MAC_CFG_PCFG_SPD_100M | |
| 692 | PAS_MAC_CFG_PCFG_TSR_100M; |
| 693 | break; |
| 694 | case 10: |
| 695 | new_flags |= PAS_MAC_CFG_PCFG_SPD_10M | |
| 696 | PAS_MAC_CFG_PCFG_TSR_10M; |
| 697 | break; |
| 698 | default: |
| 699 | printk("Unsupported speed %d\n", mac->phydev->speed); |
| 700 | } |
| 701 | |
| 702 | /* Print on link or speed/duplex change */ |
| 703 | msg = mac->link != mac->phydev->link || flags != new_flags; |
| 704 | |
| 705 | mac->duplex = mac->phydev->duplex; |
| 706 | mac->speed = mac->phydev->speed; |
| 707 | mac->link = mac->phydev->link; |
| 708 | |
| 709 | if (new_flags != flags) |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 710 | write_mac_reg(mac, PAS_MAC_CFG_PCFG, new_flags); |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 711 | |
| 712 | if (msg && netif_msg_link(mac)) |
| 713 | printk(KERN_INFO "%s: Link is up at %d Mbps, %s duplex.\n", |
| 714 | dev->name, mac->speed, mac->duplex ? "full" : "half"); |
| 715 | } |
| 716 | |
| 717 | static int pasemi_mac_phy_init(struct net_device *dev) |
| 718 | { |
| 719 | struct pasemi_mac *mac = netdev_priv(dev); |
| 720 | struct device_node *dn, *phy_dn; |
| 721 | struct phy_device *phydev; |
| 722 | unsigned int phy_id; |
| 723 | const phandle *ph; |
| 724 | const unsigned int *prop; |
| 725 | struct resource r; |
| 726 | int ret; |
| 727 | |
| 728 | dn = pci_device_to_OF_node(mac->pdev); |
Linus Torvalds | 9028780 | 2007-05-08 11:57:17 -0700 | [diff] [blame] | 729 | ph = of_get_property(dn, "phy-handle", NULL); |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 730 | if (!ph) |
| 731 | return -ENODEV; |
| 732 | phy_dn = of_find_node_by_phandle(*ph); |
| 733 | |
Linus Torvalds | 9028780 | 2007-05-08 11:57:17 -0700 | [diff] [blame] | 734 | prop = of_get_property(phy_dn, "reg", NULL); |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 735 | ret = of_address_to_resource(phy_dn->parent, 0, &r); |
| 736 | if (ret) |
| 737 | goto err; |
| 738 | |
| 739 | phy_id = *prop; |
| 740 | snprintf(mac->phy_id, BUS_ID_SIZE, PHY_ID_FMT, (int)r.start, phy_id); |
| 741 | |
| 742 | of_node_put(phy_dn); |
| 743 | |
| 744 | mac->link = 0; |
| 745 | mac->speed = 0; |
| 746 | mac->duplex = -1; |
| 747 | |
| 748 | phydev = phy_connect(dev, mac->phy_id, &pasemi_adjust_link, 0, PHY_INTERFACE_MODE_SGMII); |
| 749 | |
| 750 | if (IS_ERR(phydev)) { |
| 751 | printk(KERN_ERR "%s: Could not attach to phy\n", dev->name); |
| 752 | return PTR_ERR(phydev); |
| 753 | } |
| 754 | |
| 755 | mac->phydev = phydev; |
| 756 | |
| 757 | return 0; |
| 758 | |
| 759 | err: |
| 760 | of_node_put(phy_dn); |
| 761 | return -ENODEV; |
| 762 | } |
| 763 | |
| 764 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 765 | static int pasemi_mac_open(struct net_device *dev) |
| 766 | { |
| 767 | struct pasemi_mac *mac = netdev_priv(dev); |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 768 | int base_irq; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 769 | unsigned int flags; |
| 770 | int ret; |
| 771 | |
| 772 | /* enable rx section */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 773 | write_dma_reg(mac, PAS_DMA_COM_RXCMD, PAS_DMA_COM_RXCMD_EN); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 774 | |
| 775 | /* enable tx section */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 776 | write_dma_reg(mac, PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 777 | |
| 778 | flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) | |
| 779 | PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) | |
| 780 | PAS_MAC_CFG_TXP_TIFT(8) | PAS_MAC_CFG_TXP_TIFG(12); |
| 781 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 782 | write_mac_reg(mac, PAS_MAC_CFG_TXP, flags); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 783 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 784 | write_iob_reg(mac, PAS_IOB_DMA_RXCH_CFG(mac->dma_rxch), |
| 785 | PAS_IOB_DMA_RXCH_CFG_CNTTH(0)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 786 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 787 | write_iob_reg(mac, PAS_IOB_DMA_TXCH_CFG(mac->dma_txch), |
Olof Johansson | 02df6cf | 2007-08-22 09:13:03 -0500 | [diff] [blame] | 788 | PAS_IOB_DMA_TXCH_CFG_CNTTH(128)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 789 | |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 790 | /* Clear out any residual packet count state from firmware */ |
| 791 | pasemi_mac_restart_rx_intr(mac); |
| 792 | pasemi_mac_restart_tx_intr(mac); |
| 793 | |
Olof Johansson | 6dfa752 | 2007-05-08 00:47:32 -0500 | [diff] [blame] | 794 | /* 0xffffff is max value, about 16ms */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 795 | write_iob_reg(mac, PAS_IOB_DMA_COM_TIMEOUTCFG, |
| 796 | PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0xffffff)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 797 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 798 | ret = pasemi_mac_setup_rx_resources(dev); |
| 799 | if (ret) |
| 800 | goto out_rx_resources; |
| 801 | |
| 802 | ret = pasemi_mac_setup_tx_resources(dev); |
| 803 | if (ret) |
| 804 | goto out_tx_resources; |
| 805 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 806 | write_mac_reg(mac, PAS_MAC_IPC_CHNL, |
| 807 | PAS_MAC_IPC_CHNL_DCHNO(mac->dma_rxch) | |
| 808 | PAS_MAC_IPC_CHNL_BCH(mac->dma_rxch)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 809 | |
| 810 | /* enable rx if */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 811 | write_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac->dma_if), |
| 812 | PAS_DMA_RXINT_RCMDSTA_EN); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 813 | |
| 814 | /* enable rx channel */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 815 | write_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch), |
| 816 | PAS_DMA_RXCHAN_CCMDSTA_EN | |
| 817 | PAS_DMA_RXCHAN_CCMDSTA_DU); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 818 | |
| 819 | /* enable tx channel */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 820 | write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch), |
| 821 | PAS_DMA_TXCHAN_TCMDSTA_EN); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 822 | |
Olof Johansson | 928773c | 2007-09-26 16:25:06 -0500 | [diff] [blame^] | 823 | pasemi_mac_replenish_rx_ring(dev, RX_RING_SIZE); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 824 | |
Olof Johansson | 3603376 | 2007-09-26 16:24:42 -0500 | [diff] [blame] | 825 | flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE | |
| 826 | PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE; |
| 827 | |
| 828 | if (mac->type == MAC_TYPE_GMAC) |
| 829 | flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G; |
| 830 | else |
| 831 | flags |= PAS_MAC_CFG_PCFG_TSR_10G | PAS_MAC_CFG_PCFG_SPD_10G; |
| 832 | |
| 833 | /* Enable interface in MAC */ |
| 834 | write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags); |
| 835 | |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 836 | ret = pasemi_mac_phy_init(dev); |
| 837 | /* Some configs don't have PHYs (XAUI etc), so don't complain about |
| 838 | * failed init due to -ENODEV. |
| 839 | */ |
| 840 | if (ret && ret != -ENODEV) |
| 841 | dev_warn(&mac->pdev->dev, "phy init failed: %d\n", ret); |
| 842 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 843 | netif_start_queue(dev); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 844 | napi_enable(&mac->napi); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 845 | |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 846 | /* Interrupts are a bit different for our DMA controller: While |
| 847 | * it's got one a regular PCI device header, the interrupt there |
| 848 | * is really the base of the range it's using. Each tx and rx |
| 849 | * channel has it's own interrupt source. |
| 850 | */ |
| 851 | |
| 852 | base_irq = virq_to_hw(mac->dma_pdev->irq); |
| 853 | |
| 854 | mac->tx_irq = irq_create_mapping(NULL, base_irq + mac->dma_txch); |
| 855 | mac->rx_irq = irq_create_mapping(NULL, base_irq + 20 + mac->dma_txch); |
| 856 | |
| 857 | ret = request_irq(mac->tx_irq, &pasemi_mac_tx_intr, IRQF_DISABLED, |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 858 | mac->tx->irq_name, dev); |
| 859 | if (ret) { |
| 860 | dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n", |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 861 | base_irq + mac->dma_txch, ret); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 862 | goto out_tx_int; |
| 863 | } |
| 864 | |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 865 | ret = request_irq(mac->rx_irq, &pasemi_mac_rx_intr, IRQF_DISABLED, |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 866 | mac->rx->irq_name, dev); |
| 867 | if (ret) { |
| 868 | dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n", |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 869 | base_irq + 20 + mac->dma_rxch, ret); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 870 | goto out_rx_int; |
| 871 | } |
| 872 | |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 873 | if (mac->phydev) |
| 874 | phy_start(mac->phydev); |
| 875 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 876 | return 0; |
| 877 | |
| 878 | out_rx_int: |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 879 | free_irq(mac->tx_irq, dev); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 880 | out_tx_int: |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 881 | napi_disable(&mac->napi); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 882 | netif_stop_queue(dev); |
| 883 | pasemi_mac_free_tx_resources(dev); |
| 884 | out_tx_resources: |
| 885 | pasemi_mac_free_rx_resources(dev); |
| 886 | out_rx_resources: |
| 887 | |
| 888 | return ret; |
| 889 | } |
| 890 | |
| 891 | #define MAX_RETRIES 5000 |
| 892 | |
| 893 | static int pasemi_mac_close(struct net_device *dev) |
| 894 | { |
| 895 | struct pasemi_mac *mac = netdev_priv(dev); |
| 896 | unsigned int stat; |
| 897 | int retries; |
| 898 | |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 899 | if (mac->phydev) { |
| 900 | phy_stop(mac->phydev); |
| 901 | phy_disconnect(mac->phydev); |
| 902 | } |
| 903 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 904 | netif_stop_queue(dev); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 905 | napi_disable(&mac->napi); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 906 | |
| 907 | /* Clean out any pending buffers */ |
| 908 | pasemi_mac_clean_tx(mac); |
| 909 | pasemi_mac_clean_rx(mac, RX_RING_SIZE); |
| 910 | |
| 911 | /* Disable interface */ |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 912 | write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch), PAS_DMA_TXCHAN_TCMDSTA_ST); |
| 913 | write_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac->dma_if), PAS_DMA_RXINT_RCMDSTA_ST); |
| 914 | write_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch), PAS_DMA_RXCHAN_CCMDSTA_ST); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 915 | |
| 916 | for (retries = 0; retries < MAX_RETRIES; retries++) { |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 917 | stat = read_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch)); |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 918 | if (!(stat & PAS_DMA_TXCHAN_TCMDSTA_ACT)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 919 | break; |
| 920 | cond_resched(); |
| 921 | } |
| 922 | |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 923 | if (stat & PAS_DMA_TXCHAN_TCMDSTA_ACT) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 924 | dev_err(&mac->dma_pdev->dev, "Failed to stop tx channel\n"); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 925 | |
| 926 | for (retries = 0; retries < MAX_RETRIES; retries++) { |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 927 | stat = read_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch)); |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 928 | if (!(stat & PAS_DMA_RXCHAN_CCMDSTA_ACT)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 929 | break; |
| 930 | cond_resched(); |
| 931 | } |
| 932 | |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 933 | if (stat & PAS_DMA_RXCHAN_CCMDSTA_ACT) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 934 | dev_err(&mac->dma_pdev->dev, "Failed to stop rx channel\n"); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 935 | |
| 936 | for (retries = 0; retries < MAX_RETRIES; retries++) { |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 937 | stat = read_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac->dma_if)); |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 938 | if (!(stat & PAS_DMA_RXINT_RCMDSTA_ACT)) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 939 | break; |
| 940 | cond_resched(); |
| 941 | } |
| 942 | |
Olof Johansson | 0ce68c7 | 2007-04-28 15:36:40 -0500 | [diff] [blame] | 943 | if (stat & PAS_DMA_RXINT_RCMDSTA_ACT) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 944 | dev_err(&mac->dma_pdev->dev, "Failed to stop rx interface\n"); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 945 | |
| 946 | /* Then, disable the channel. This must be done separately from |
| 947 | * stopping, since you can't disable when active. |
| 948 | */ |
| 949 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 950 | write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch), 0); |
| 951 | write_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch), 0); |
| 952 | write_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac->dma_if), 0); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 953 | |
Olof Johansson | 771f740 | 2007-05-08 00:47:21 -0500 | [diff] [blame] | 954 | free_irq(mac->tx_irq, dev); |
| 955 | free_irq(mac->rx_irq, dev); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 956 | |
| 957 | /* Free resources */ |
| 958 | pasemi_mac_free_rx_resources(dev); |
| 959 | pasemi_mac_free_tx_resources(dev); |
| 960 | |
| 961 | return 0; |
| 962 | } |
| 963 | |
| 964 | static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev) |
| 965 | { |
| 966 | struct pasemi_mac *mac = netdev_priv(dev); |
| 967 | struct pasemi_mac_txring *txring; |
| 968 | struct pasemi_mac_buffer *info; |
| 969 | struct pas_dma_xct_descr *dp; |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 970 | u64 dflags, mactx, ptr; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 971 | dma_addr_t map; |
Olof Johansson | ca7e235 | 2007-09-26 16:23:59 -0500 | [diff] [blame] | 972 | unsigned long flags; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 973 | |
| 974 | dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_SS | XCT_MACTX_CRC_PAD; |
| 975 | |
| 976 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
Arnaldo Carvalho de Melo | d56f90a | 2007-04-10 20:50:43 -0700 | [diff] [blame] | 977 | const unsigned char *nh = skb_network_header(skb); |
| 978 | |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 979 | switch (ip_hdr(skb)->protocol) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 980 | case IPPROTO_TCP: |
| 981 | dflags |= XCT_MACTX_CSUM_TCP; |
Arnaldo Carvalho de Melo | cfe1fc7 | 2007-03-16 17:26:39 -0300 | [diff] [blame] | 982 | dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2); |
Arnaldo Carvalho de Melo | d56f90a | 2007-04-10 20:50:43 -0700 | [diff] [blame] | 983 | dflags |= XCT_MACTX_IPO(nh - skb->data); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 984 | break; |
| 985 | case IPPROTO_UDP: |
| 986 | dflags |= XCT_MACTX_CSUM_UDP; |
Arnaldo Carvalho de Melo | cfe1fc7 | 2007-03-16 17:26:39 -0300 | [diff] [blame] | 987 | dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2); |
Arnaldo Carvalho de Melo | d56f90a | 2007-04-10 20:50:43 -0700 | [diff] [blame] | 988 | dflags |= XCT_MACTX_IPO(nh - skb->data); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 989 | break; |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | map = pci_map_single(mac->dma_pdev, skb->data, skb->len, PCI_DMA_TODEVICE); |
| 994 | |
| 995 | if (dma_mapping_error(map)) |
| 996 | return NETDEV_TX_BUSY; |
| 997 | |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 998 | mactx = dflags | XCT_MACTX_LLEN(skb->len); |
| 999 | ptr = XCT_PTR_LEN(skb->len) | XCT_PTR_ADDR(map); |
| 1000 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1001 | txring = mac->tx; |
| 1002 | |
| 1003 | spin_lock_irqsave(&txring->lock, flags); |
| 1004 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 1005 | if (RING_AVAIL(txring) <= 1) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1006 | spin_unlock_irqrestore(&txring->lock, flags); |
| 1007 | pasemi_mac_clean_tx(mac); |
Olof Johansson | 52a9435 | 2007-05-12 18:01:09 -0500 | [diff] [blame] | 1008 | pasemi_mac_restart_tx_intr(mac); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1009 | spin_lock_irqsave(&txring->lock, flags); |
| 1010 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 1011 | if (RING_AVAIL(txring) <= 1) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1012 | /* Still no room -- stop the queue and wait for tx |
| 1013 | * intr when there's room. |
| 1014 | */ |
| 1015 | netif_stop_queue(dev); |
| 1016 | goto out_err; |
| 1017 | } |
| 1018 | } |
| 1019 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 1020 | dp = &TX_DESC(mac, txring->next_to_fill); |
| 1021 | info = &TX_DESC_INFO(mac, txring->next_to_fill); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1022 | |
Olof Johansson | 26fcfa9 | 2007-08-22 09:12:59 -0500 | [diff] [blame] | 1023 | dp->mactx = mactx; |
| 1024 | dp->ptr = ptr; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1025 | info->dma = map; |
| 1026 | info->skb = skb; |
| 1027 | |
Olof Johansson | 021fa22 | 2007-08-22 09:13:11 -0500 | [diff] [blame] | 1028 | txring->next_to_fill++; |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1029 | dev->stats.tx_packets++; |
| 1030 | dev->stats.tx_bytes += skb->len; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1031 | |
| 1032 | spin_unlock_irqrestore(&txring->lock, flags); |
| 1033 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 1034 | write_dma_reg(mac, PAS_DMA_TXCHAN_INCR(mac->dma_txch), 1); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1035 | |
| 1036 | return NETDEV_TX_OK; |
| 1037 | |
| 1038 | out_err: |
| 1039 | spin_unlock_irqrestore(&txring->lock, flags); |
| 1040 | pci_unmap_single(mac->dma_pdev, map, skb->len, PCI_DMA_TODEVICE); |
| 1041 | return NETDEV_TX_BUSY; |
| 1042 | } |
| 1043 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1044 | static void pasemi_mac_set_rx_mode(struct net_device *dev) |
| 1045 | { |
| 1046 | struct pasemi_mac *mac = netdev_priv(dev); |
| 1047 | unsigned int flags; |
| 1048 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 1049 | flags = read_mac_reg(mac, PAS_MAC_CFG_PCFG); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1050 | |
| 1051 | /* Set promiscuous */ |
| 1052 | if (dev->flags & IFF_PROMISC) |
| 1053 | flags |= PAS_MAC_CFG_PCFG_PR; |
| 1054 | else |
| 1055 | flags &= ~PAS_MAC_CFG_PCFG_PR; |
| 1056 | |
Olof Johansson | a85b942 | 2007-09-15 13:40:59 -0700 | [diff] [blame] | 1057 | write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1061 | static int pasemi_mac_poll(struct napi_struct *napi, int budget) |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1062 | { |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1063 | struct pasemi_mac *mac = container_of(napi, struct pasemi_mac, napi); |
| 1064 | struct net_device *dev = mac->netdev; |
| 1065 | int pkts; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1066 | |
Olof Johansson | 829185e | 2007-09-15 13:53:19 -0700 | [diff] [blame] | 1067 | pasemi_mac_clean_tx(mac); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1068 | pkts = pasemi_mac_clean_rx(mac, budget); |
| 1069 | if (pkts < budget) { |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1070 | /* all done, no more packets present */ |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1071 | netif_rx_complete(dev, napi); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1072 | |
Olof Johansson | 1b0335ea | 2007-05-08 00:47:26 -0500 | [diff] [blame] | 1073 | pasemi_mac_restart_rx_intr(mac); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1074 | } |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1075 | return pkts; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1076 | } |
| 1077 | |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 1078 | static void __iomem * __devinit map_onedev(struct pci_dev *p, int index) |
| 1079 | { |
| 1080 | struct device_node *dn; |
| 1081 | void __iomem *ret; |
| 1082 | |
| 1083 | dn = pci_device_to_OF_node(p); |
| 1084 | if (!dn) |
| 1085 | goto fallback; |
| 1086 | |
| 1087 | ret = of_iomap(dn, index); |
| 1088 | if (!ret) |
| 1089 | goto fallback; |
| 1090 | |
| 1091 | return ret; |
| 1092 | fallback: |
| 1093 | /* This is hardcoded and ugly, but we have some firmware versions |
| 1094 | * that don't provide the register space in the device tree. Luckily |
| 1095 | * they are at well-known locations so we can just do the math here. |
| 1096 | */ |
| 1097 | return ioremap(0xe0000000 + (p->devfn << 12), 0x2000); |
| 1098 | } |
| 1099 | |
| 1100 | static int __devinit pasemi_mac_map_regs(struct pasemi_mac *mac) |
| 1101 | { |
| 1102 | struct resource res; |
| 1103 | struct device_node *dn; |
| 1104 | int err; |
| 1105 | |
| 1106 | mac->dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL); |
| 1107 | if (!mac->dma_pdev) { |
| 1108 | dev_err(&mac->pdev->dev, "Can't find DMA Controller\n"); |
| 1109 | return -ENODEV; |
| 1110 | } |
| 1111 | |
| 1112 | mac->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL); |
| 1113 | if (!mac->iob_pdev) { |
| 1114 | dev_err(&mac->pdev->dev, "Can't find I/O Bridge\n"); |
| 1115 | return -ENODEV; |
| 1116 | } |
| 1117 | |
| 1118 | mac->regs = map_onedev(mac->pdev, 0); |
| 1119 | mac->dma_regs = map_onedev(mac->dma_pdev, 0); |
| 1120 | mac->iob_regs = map_onedev(mac->iob_pdev, 0); |
| 1121 | |
| 1122 | if (!mac->regs || !mac->dma_regs || !mac->iob_regs) { |
| 1123 | dev_err(&mac->pdev->dev, "Can't map registers\n"); |
| 1124 | return -ENODEV; |
| 1125 | } |
| 1126 | |
| 1127 | /* The dma status structure is located in the I/O bridge, and |
| 1128 | * is cache coherent. |
| 1129 | */ |
| 1130 | if (!dma_status) { |
| 1131 | dn = pci_device_to_OF_node(mac->iob_pdev); |
| 1132 | if (dn) |
| 1133 | err = of_address_to_resource(dn, 1, &res); |
| 1134 | if (!dn || err) { |
| 1135 | /* Fallback for old firmware */ |
| 1136 | res.start = 0xfd800000; |
| 1137 | res.end = res.start + 0x1000; |
| 1138 | } |
| 1139 | dma_status = __ioremap(res.start, res.end-res.start, 0); |
| 1140 | } |
| 1141 | |
| 1142 | return 0; |
| 1143 | } |
| 1144 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1145 | static int __devinit |
| 1146 | pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 1147 | { |
| 1148 | static int index = 0; |
| 1149 | struct net_device *dev; |
| 1150 | struct pasemi_mac *mac; |
| 1151 | int err; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1152 | DECLARE_MAC_BUF(mac_buf); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1153 | |
| 1154 | err = pci_enable_device(pdev); |
| 1155 | if (err) |
| 1156 | return err; |
| 1157 | |
| 1158 | dev = alloc_etherdev(sizeof(struct pasemi_mac)); |
| 1159 | if (dev == NULL) { |
| 1160 | dev_err(&pdev->dev, |
| 1161 | "pasemi_mac: Could not allocate ethernet device.\n"); |
| 1162 | err = -ENOMEM; |
| 1163 | goto out_disable_device; |
| 1164 | } |
| 1165 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1166 | pci_set_drvdata(pdev, dev); |
| 1167 | SET_NETDEV_DEV(dev, &pdev->dev); |
| 1168 | |
| 1169 | mac = netdev_priv(dev); |
| 1170 | |
| 1171 | mac->pdev = pdev; |
| 1172 | mac->netdev = dev; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1173 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1174 | netif_napi_add(dev, &mac->napi, pasemi_mac_poll, 64); |
| 1175 | |
Olof Johansson | 6fba848 | 2007-09-15 13:51:11 -0700 | [diff] [blame] | 1176 | dev->features = NETIF_F_HW_CSUM | NETIF_F_LLTX; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1177 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1178 | /* These should come out of the device tree eventually */ |
| 1179 | mac->dma_txch = index; |
| 1180 | mac->dma_rxch = index; |
| 1181 | |
| 1182 | /* We probe GMAC before XAUI, but the DMA interfaces are |
| 1183 | * in XAUI, GMAC order. |
| 1184 | */ |
| 1185 | if (index < 4) |
| 1186 | mac->dma_if = index + 2; |
| 1187 | else |
| 1188 | mac->dma_if = index - 4; |
| 1189 | index++; |
| 1190 | |
| 1191 | switch (pdev->device) { |
| 1192 | case 0xa005: |
| 1193 | mac->type = MAC_TYPE_GMAC; |
| 1194 | break; |
| 1195 | case 0xa006: |
| 1196 | mac->type = MAC_TYPE_XAUI; |
| 1197 | break; |
| 1198 | default: |
| 1199 | err = -ENODEV; |
| 1200 | goto out; |
| 1201 | } |
| 1202 | |
| 1203 | /* get mac addr from device tree */ |
| 1204 | if (pasemi_get_mac_addr(mac) || !is_valid_ether_addr(mac->mac_addr)) { |
| 1205 | err = -ENODEV; |
| 1206 | goto out; |
| 1207 | } |
| 1208 | memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr)); |
| 1209 | |
| 1210 | dev->open = pasemi_mac_open; |
| 1211 | dev->stop = pasemi_mac_close; |
| 1212 | dev->hard_start_xmit = pasemi_mac_start_tx; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1213 | dev->set_multicast_list = pasemi_mac_set_rx_mode; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1214 | |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 1215 | err = pasemi_mac_map_regs(mac); |
| 1216 | if (err) |
| 1217 | goto out; |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1218 | |
| 1219 | mac->rx_status = &dma_status->rx_sta[mac->dma_rxch]; |
| 1220 | mac->tx_status = &dma_status->tx_sta[mac->dma_txch]; |
| 1221 | |
Olof Johansson | ceb5136 | 2007-05-08 00:47:49 -0500 | [diff] [blame] | 1222 | mac->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); |
| 1223 | |
Olof Johansson | bb6e959 | 2007-05-08 00:47:54 -0500 | [diff] [blame] | 1224 | /* Enable most messages by default */ |
| 1225 | mac->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1; |
| 1226 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1227 | err = register_netdev(dev); |
| 1228 | |
| 1229 | if (err) { |
| 1230 | dev_err(&mac->pdev->dev, "register_netdev failed with error %d\n", |
| 1231 | err); |
| 1232 | goto out; |
| 1233 | } else |
| 1234 | printk(KERN_INFO "%s: PA Semi %s: intf %d, txch %d, rxch %d, " |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1235 | "hw addr %s\n", |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1236 | dev->name, mac->type == MAC_TYPE_GMAC ? "GMAC" : "XAUI", |
| 1237 | mac->dma_if, mac->dma_txch, mac->dma_rxch, |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1238 | print_mac(mac_buf, dev->dev_addr)); |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1239 | |
| 1240 | return err; |
| 1241 | |
| 1242 | out: |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 1243 | if (mac->iob_pdev) |
| 1244 | pci_dev_put(mac->iob_pdev); |
| 1245 | if (mac->dma_pdev) |
| 1246 | pci_dev_put(mac->dma_pdev); |
| 1247 | if (mac->dma_regs) |
| 1248 | iounmap(mac->dma_regs); |
| 1249 | if (mac->iob_regs) |
| 1250 | iounmap(mac->iob_regs); |
| 1251 | if (mac->regs) |
| 1252 | iounmap(mac->regs); |
| 1253 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1254 | free_netdev(dev); |
| 1255 | out_disable_device: |
| 1256 | pci_disable_device(pdev); |
| 1257 | return err; |
| 1258 | |
| 1259 | } |
| 1260 | |
| 1261 | static void __devexit pasemi_mac_remove(struct pci_dev *pdev) |
| 1262 | { |
| 1263 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 1264 | struct pasemi_mac *mac; |
| 1265 | |
| 1266 | if (!netdev) |
| 1267 | return; |
| 1268 | |
| 1269 | mac = netdev_priv(netdev); |
| 1270 | |
| 1271 | unregister_netdev(netdev); |
| 1272 | |
| 1273 | pci_disable_device(pdev); |
| 1274 | pci_dev_put(mac->dma_pdev); |
| 1275 | pci_dev_put(mac->iob_pdev); |
| 1276 | |
Olof Johansson | b6e05a1 | 2007-09-15 13:44:07 -0700 | [diff] [blame] | 1277 | iounmap(mac->regs); |
| 1278 | iounmap(mac->dma_regs); |
| 1279 | iounmap(mac->iob_regs); |
| 1280 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1281 | pci_set_drvdata(pdev, NULL); |
| 1282 | free_netdev(netdev); |
| 1283 | } |
| 1284 | |
| 1285 | static struct pci_device_id pasemi_mac_pci_tbl[] = { |
| 1286 | { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa005) }, |
| 1287 | { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa006) }, |
olof@lixom.net | fd17825 | 2007-05-12 14:57:36 -0500 | [diff] [blame] | 1288 | { }, |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1289 | }; |
| 1290 | |
| 1291 | MODULE_DEVICE_TABLE(pci, pasemi_mac_pci_tbl); |
| 1292 | |
| 1293 | static struct pci_driver pasemi_mac_driver = { |
| 1294 | .name = "pasemi_mac", |
| 1295 | .id_table = pasemi_mac_pci_tbl, |
| 1296 | .probe = pasemi_mac_probe, |
| 1297 | .remove = __devexit_p(pasemi_mac_remove), |
| 1298 | }; |
| 1299 | |
| 1300 | static void __exit pasemi_mac_cleanup_module(void) |
| 1301 | { |
| 1302 | pci_unregister_driver(&pasemi_mac_driver); |
| 1303 | __iounmap(dma_status); |
| 1304 | dma_status = NULL; |
| 1305 | } |
| 1306 | |
| 1307 | int pasemi_mac_init_module(void) |
| 1308 | { |
| 1309 | return pci_register_driver(&pasemi_mac_driver); |
| 1310 | } |
| 1311 | |
Olof Johansson | f5cd787 | 2007-01-31 21:43:54 -0600 | [diff] [blame] | 1312 | module_init(pasemi_mac_init_module); |
| 1313 | module_exit(pasemi_mac_cleanup_module); |