diff options
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/sundance.c | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index 7dfdbee878e8..5b786ce2b5f1 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c | |||
@@ -96,6 +96,7 @@ static char *media[MAX_UNITS]; | |||
96 | #include <asm/io.h> | 96 | #include <asm/io.h> |
97 | #include <linux/delay.h> | 97 | #include <linux/delay.h> |
98 | #include <linux/spinlock.h> | 98 | #include <linux/spinlock.h> |
99 | #include <linux/dma-mapping.h> | ||
99 | #ifndef _COMPAT_WITH_OLD_KERNEL | 100 | #ifndef _COMPAT_WITH_OLD_KERNEL |
100 | #include <linux/crc32.h> | 101 | #include <linux/crc32.h> |
101 | #include <linux/ethtool.h> | 102 | #include <linux/ethtool.h> |
@@ -523,13 +524,15 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev, | |||
523 | tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev); | 524 | tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev); |
524 | tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev); | 525 | tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev); |
525 | 526 | ||
526 | ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma); | 527 | ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE, |
528 | &ring_dma, GFP_KERNEL); | ||
527 | if (!ring_space) | 529 | if (!ring_space) |
528 | goto err_out_cleardev; | 530 | goto err_out_cleardev; |
529 | np->tx_ring = (struct netdev_desc *)ring_space; | 531 | np->tx_ring = (struct netdev_desc *)ring_space; |
530 | np->tx_ring_dma = ring_dma; | 532 | np->tx_ring_dma = ring_dma; |
531 | 533 | ||
532 | ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma); | 534 | ring_space = dma_alloc_coherent(&pdev->dev, RX_TOTAL_SIZE, |
535 | &ring_dma, GFP_KERNEL); | ||
533 | if (!ring_space) | 536 | if (!ring_space) |
534 | goto err_out_unmap_tx; | 537 | goto err_out_unmap_tx; |
535 | np->rx_ring = (struct netdev_desc *)ring_space; | 538 | np->rx_ring = (struct netdev_desc *)ring_space; |
@@ -663,9 +666,11 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev, | |||
663 | err_out_unregister: | 666 | err_out_unregister: |
664 | unregister_netdev(dev); | 667 | unregister_netdev(dev); |
665 | err_out_unmap_rx: | 668 | err_out_unmap_rx: |
666 | pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma); | 669 | dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, |
670 | np->rx_ring, np->rx_ring_dma); | ||
667 | err_out_unmap_tx: | 671 | err_out_unmap_tx: |
668 | pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma); | 672 | dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, |
673 | np->tx_ring, np->tx_ring_dma); | ||
669 | err_out_cleardev: | 674 | err_out_cleardev: |
670 | pci_set_drvdata(pdev, NULL); | 675 | pci_set_drvdata(pdev, NULL); |
671 | pci_iounmap(pdev, ioaddr); | 676 | pci_iounmap(pdev, ioaddr); |
@@ -1011,8 +1016,8 @@ static void init_ring(struct net_device *dev) | |||
1011 | skb->dev = dev; /* Mark as being used by this device. */ | 1016 | skb->dev = dev; /* Mark as being used by this device. */ |
1012 | skb_reserve(skb, 2); /* 16 byte align the IP header. */ | 1017 | skb_reserve(skb, 2); /* 16 byte align the IP header. */ |
1013 | np->rx_ring[i].frag[0].addr = cpu_to_le32( | 1018 | np->rx_ring[i].frag[0].addr = cpu_to_le32( |
1014 | pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, | 1019 | dma_map_single(&np->pci_dev->dev, skb->data, |
1015 | PCI_DMA_FROMDEVICE)); | 1020 | np->rx_buf_sz, DMA_FROM_DEVICE)); |
1016 | np->rx_ring[i].frag[0].length = cpu_to_le32(np->rx_buf_sz | LastFrag); | 1021 | np->rx_ring[i].frag[0].length = cpu_to_le32(np->rx_buf_sz | LastFrag); |
1017 | } | 1022 | } |
1018 | np->dirty_rx = (unsigned int)(i - RX_RING_SIZE); | 1023 | np->dirty_rx = (unsigned int)(i - RX_RING_SIZE); |
@@ -1063,9 +1068,8 @@ start_tx (struct sk_buff *skb, struct net_device *dev) | |||
1063 | 1068 | ||
1064 | txdesc->next_desc = 0; | 1069 | txdesc->next_desc = 0; |
1065 | txdesc->status = cpu_to_le32 ((entry << 2) | DisableAlign); | 1070 | txdesc->status = cpu_to_le32 ((entry << 2) | DisableAlign); |
1066 | txdesc->frag[0].addr = cpu_to_le32 (pci_map_single (np->pci_dev, skb->data, | 1071 | txdesc->frag[0].addr = cpu_to_le32(dma_map_single(&np->pci_dev->dev, |
1067 | skb->len, | 1072 | skb->data, skb->len, DMA_TO_DEVICE)); |
1068 | PCI_DMA_TODEVICE)); | ||
1069 | txdesc->frag[0].length = cpu_to_le32 (skb->len | LastFrag); | 1073 | txdesc->frag[0].length = cpu_to_le32 (skb->len | LastFrag); |
1070 | 1074 | ||
1071 | /* Increment cur_tx before tasklet_schedule() */ | 1075 | /* Increment cur_tx before tasklet_schedule() */ |
@@ -1109,9 +1113,9 @@ reset_tx (struct net_device *dev) | |||
1109 | 1113 | ||
1110 | skb = np->tx_skbuff[i]; | 1114 | skb = np->tx_skbuff[i]; |
1111 | if (skb) { | 1115 | if (skb) { |
1112 | pci_unmap_single(np->pci_dev, | 1116 | dma_unmap_single(&np->pci_dev->dev, |
1113 | le32_to_cpu(np->tx_ring[i].frag[0].addr), | 1117 | le32_to_cpu(np->tx_ring[i].frag[0].addr), |
1114 | skb->len, PCI_DMA_TODEVICE); | 1118 | skb->len, DMA_TO_DEVICE); |
1115 | if (irq) | 1119 | if (irq) |
1116 | dev_kfree_skb_irq (skb); | 1120 | dev_kfree_skb_irq (skb); |
1117 | else | 1121 | else |
@@ -1233,9 +1237,9 @@ static irqreturn_t intr_handler(int irq, void *dev_instance) | |||
1233 | break; | 1237 | break; |
1234 | skb = np->tx_skbuff[entry]; | 1238 | skb = np->tx_skbuff[entry]; |
1235 | /* Free the original skb. */ | 1239 | /* Free the original skb. */ |
1236 | pci_unmap_single(np->pci_dev, | 1240 | dma_unmap_single(&np->pci_dev->dev, |
1237 | le32_to_cpu(np->tx_ring[entry].frag[0].addr), | 1241 | le32_to_cpu(np->tx_ring[entry].frag[0].addr), |
1238 | skb->len, PCI_DMA_TODEVICE); | 1242 | skb->len, DMA_TO_DEVICE); |
1239 | dev_kfree_skb_irq (np->tx_skbuff[entry]); | 1243 | dev_kfree_skb_irq (np->tx_skbuff[entry]); |
1240 | np->tx_skbuff[entry] = NULL; | 1244 | np->tx_skbuff[entry] = NULL; |
1241 | np->tx_ring[entry].frag[0].addr = 0; | 1245 | np->tx_ring[entry].frag[0].addr = 0; |
@@ -1252,9 +1256,9 @@ static irqreturn_t intr_handler(int irq, void *dev_instance) | |||
1252 | break; | 1256 | break; |
1253 | skb = np->tx_skbuff[entry]; | 1257 | skb = np->tx_skbuff[entry]; |
1254 | /* Free the original skb. */ | 1258 | /* Free the original skb. */ |
1255 | pci_unmap_single(np->pci_dev, | 1259 | dma_unmap_single(&np->pci_dev->dev, |
1256 | le32_to_cpu(np->tx_ring[entry].frag[0].addr), | 1260 | le32_to_cpu(np->tx_ring[entry].frag[0].addr), |
1257 | skb->len, PCI_DMA_TODEVICE); | 1261 | skb->len, DMA_TO_DEVICE); |
1258 | dev_kfree_skb_irq (np->tx_skbuff[entry]); | 1262 | dev_kfree_skb_irq (np->tx_skbuff[entry]); |
1259 | np->tx_skbuff[entry] = NULL; | 1263 | np->tx_skbuff[entry] = NULL; |
1260 | np->tx_ring[entry].frag[0].addr = 0; | 1264 | np->tx_ring[entry].frag[0].addr = 0; |
@@ -1334,22 +1338,18 @@ static void rx_poll(unsigned long data) | |||
1334 | if (pkt_len < rx_copybreak && | 1338 | if (pkt_len < rx_copybreak && |
1335 | (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { | 1339 | (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { |
1336 | skb_reserve(skb, 2); /* 16 byte align the IP header */ | 1340 | skb_reserve(skb, 2); /* 16 byte align the IP header */ |
1337 | pci_dma_sync_single_for_cpu(np->pci_dev, | 1341 | dma_sync_single_for_cpu(&np->pci_dev->dev, |
1338 | le32_to_cpu(desc->frag[0].addr), | 1342 | le32_to_cpu(desc->frag[0].addr), |
1339 | np->rx_buf_sz, | 1343 | np->rx_buf_sz, DMA_FROM_DEVICE); |
1340 | PCI_DMA_FROMDEVICE); | ||
1341 | |||
1342 | skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); | 1344 | skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); |
1343 | pci_dma_sync_single_for_device(np->pci_dev, | 1345 | dma_sync_single_for_device(&np->pci_dev->dev, |
1344 | le32_to_cpu(desc->frag[0].addr), | 1346 | le32_to_cpu(desc->frag[0].addr), |
1345 | np->rx_buf_sz, | 1347 | np->rx_buf_sz, DMA_FROM_DEVICE); |
1346 | PCI_DMA_FROMDEVICE); | ||
1347 | skb_put(skb, pkt_len); | 1348 | skb_put(skb, pkt_len); |
1348 | } else { | 1349 | } else { |
1349 | pci_unmap_single(np->pci_dev, | 1350 | dma_unmap_single(&np->pci_dev->dev, |
1350 | le32_to_cpu(desc->frag[0].addr), | 1351 | le32_to_cpu(desc->frag[0].addr), |
1351 | np->rx_buf_sz, | 1352 | np->rx_buf_sz, DMA_FROM_DEVICE); |
1352 | PCI_DMA_FROMDEVICE); | ||
1353 | skb_put(skb = np->rx_skbuff[entry], pkt_len); | 1353 | skb_put(skb = np->rx_skbuff[entry], pkt_len); |
1354 | np->rx_skbuff[entry] = NULL; | 1354 | np->rx_skbuff[entry] = NULL; |
1355 | } | 1355 | } |
@@ -1396,8 +1396,8 @@ static void refill_rx (struct net_device *dev) | |||
1396 | skb->dev = dev; /* Mark as being used by this device. */ | 1396 | skb->dev = dev; /* Mark as being used by this device. */ |
1397 | skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ | 1397 | skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ |
1398 | np->rx_ring[entry].frag[0].addr = cpu_to_le32( | 1398 | np->rx_ring[entry].frag[0].addr = cpu_to_le32( |
1399 | pci_map_single(np->pci_dev, skb->data, | 1399 | dma_map_single(&np->pci_dev->dev, skb->data, |
1400 | np->rx_buf_sz, PCI_DMA_FROMDEVICE)); | 1400 | np->rx_buf_sz, DMA_FROM_DEVICE)); |
1401 | } | 1401 | } |
1402 | /* Perhaps we need not reset this field. */ | 1402 | /* Perhaps we need not reset this field. */ |
1403 | np->rx_ring[entry].frag[0].length = | 1403 | np->rx_ring[entry].frag[0].length = |
@@ -1715,9 +1715,9 @@ static int netdev_close(struct net_device *dev) | |||
1715 | np->rx_ring[i].status = 0; | 1715 | np->rx_ring[i].status = 0; |
1716 | skb = np->rx_skbuff[i]; | 1716 | skb = np->rx_skbuff[i]; |
1717 | if (skb) { | 1717 | if (skb) { |
1718 | pci_unmap_single(np->pci_dev, | 1718 | dma_unmap_single(&np->pci_dev->dev, |
1719 | le32_to_cpu(np->rx_ring[i].frag[0].addr), | 1719 | le32_to_cpu(np->rx_ring[i].frag[0].addr), |
1720 | np->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1720 | np->rx_buf_sz, DMA_FROM_DEVICE); |
1721 | dev_kfree_skb(skb); | 1721 | dev_kfree_skb(skb); |
1722 | np->rx_skbuff[i] = NULL; | 1722 | np->rx_skbuff[i] = NULL; |
1723 | } | 1723 | } |
@@ -1727,9 +1727,9 @@ static int netdev_close(struct net_device *dev) | |||
1727 | np->tx_ring[i].next_desc = 0; | 1727 | np->tx_ring[i].next_desc = 0; |
1728 | skb = np->tx_skbuff[i]; | 1728 | skb = np->tx_skbuff[i]; |
1729 | if (skb) { | 1729 | if (skb) { |
1730 | pci_unmap_single(np->pci_dev, | 1730 | dma_unmap_single(&np->pci_dev->dev, |
1731 | le32_to_cpu(np->tx_ring[i].frag[0].addr), | 1731 | le32_to_cpu(np->tx_ring[i].frag[0].addr), |
1732 | skb->len, PCI_DMA_TODEVICE); | 1732 | skb->len, DMA_TO_DEVICE); |
1733 | dev_kfree_skb(skb); | 1733 | dev_kfree_skb(skb); |
1734 | np->tx_skbuff[i] = NULL; | 1734 | np->tx_skbuff[i] = NULL; |
1735 | } | 1735 | } |
@@ -1743,17 +1743,16 @@ static void __devexit sundance_remove1 (struct pci_dev *pdev) | |||
1743 | struct net_device *dev = pci_get_drvdata(pdev); | 1743 | struct net_device *dev = pci_get_drvdata(pdev); |
1744 | 1744 | ||
1745 | if (dev) { | 1745 | if (dev) { |
1746 | struct netdev_private *np = netdev_priv(dev); | 1746 | struct netdev_private *np = netdev_priv(dev); |
1747 | 1747 | unregister_netdev(dev); | |
1748 | unregister_netdev(dev); | 1748 | dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, |
1749 | pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, | 1749 | np->rx_ring, np->rx_ring_dma); |
1750 | np->rx_ring_dma); | 1750 | dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, |
1751 | pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, | 1751 | np->tx_ring, np->tx_ring_dma); |
1752 | np->tx_ring_dma); | 1752 | pci_iounmap(pdev, np->base); |
1753 | pci_iounmap(pdev, np->base); | 1753 | pci_release_regions(pdev); |
1754 | pci_release_regions(pdev); | 1754 | free_netdev(dev); |
1755 | free_netdev(dev); | 1755 | pci_set_drvdata(pdev, NULL); |
1756 | pci_set_drvdata(pdev, NULL); | ||
1757 | } | 1756 | } |
1758 | } | 1757 | } |
1759 | 1758 | ||