| .. | .. |
|---|
| 25 | 25 | */ |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | #define DRV_NAME "fealnx" |
|---|
| 28 | | -#define DRV_VERSION "2.52" |
|---|
| 29 | | -#define DRV_RELDATE "Sep-11-2006" |
|---|
| 30 | 28 | |
|---|
| 31 | 29 | static int debug; /* 1-> print debug message */ |
|---|
| 32 | 30 | static int max_interrupt_work = 20; |
|---|
| .. | .. |
|---|
| 90 | 88 | #include <asm/io.h> |
|---|
| 91 | 89 | #include <linux/uaccess.h> |
|---|
| 92 | 90 | #include <asm/byteorder.h> |
|---|
| 93 | | - |
|---|
| 94 | | -/* These identify the driver base version and may not be removed. */ |
|---|
| 95 | | -static const char version[] = |
|---|
| 96 | | - KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE "\n"; |
|---|
| 97 | | - |
|---|
| 98 | 91 | |
|---|
| 99 | 92 | /* This driver was written to use PCI memory space, however some x86 systems |
|---|
| 100 | 93 | work only with I/O space accesses. */ |
|---|
| .. | .. |
|---|
| 428 | 421 | static void getlinkstatus(struct net_device *dev); |
|---|
| 429 | 422 | static void netdev_timer(struct timer_list *t); |
|---|
| 430 | 423 | static void reset_timer(struct timer_list *t); |
|---|
| 431 | | -static void fealnx_tx_timeout(struct net_device *dev); |
|---|
| 424 | +static void fealnx_tx_timeout(struct net_device *dev, unsigned int txqueue); |
|---|
| 432 | 425 | static void init_ring(struct net_device *dev); |
|---|
| 433 | 426 | static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev); |
|---|
| 434 | 427 | static irqreturn_t intr_handler(int irq, void *dev_instance); |
|---|
| .. | .. |
|---|
| 495 | 488 | int bar = 1; |
|---|
| 496 | 489 | #endif |
|---|
| 497 | 490 | |
|---|
| 498 | | -/* when built into the kernel, we only print version if device is found */ |
|---|
| 499 | | -#ifndef MODULE |
|---|
| 500 | | - static int printed_version; |
|---|
| 501 | | - if (!printed_version++) |
|---|
| 502 | | - printk(version); |
|---|
| 503 | | -#endif |
|---|
| 504 | | - |
|---|
| 505 | 491 | card_idx++; |
|---|
| 506 | 492 | sprintf(boardname, "fealnx%d", card_idx); |
|---|
| 507 | 493 | |
|---|
| .. | .. |
|---|
| 557 | 543 | np->mii.phy_id_mask = 0x1f; |
|---|
| 558 | 544 | np->mii.reg_num_mask = 0x1f; |
|---|
| 559 | 545 | |
|---|
| 560 | | - ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma); |
|---|
| 546 | + ring_space = dma_alloc_coherent(&pdev->dev, RX_TOTAL_SIZE, &ring_dma, |
|---|
| 547 | + GFP_KERNEL); |
|---|
| 561 | 548 | if (!ring_space) { |
|---|
| 562 | 549 | err = -ENOMEM; |
|---|
| 563 | 550 | goto err_out_free_dev; |
|---|
| .. | .. |
|---|
| 565 | 552 | np->rx_ring = ring_space; |
|---|
| 566 | 553 | np->rx_ring_dma = ring_dma; |
|---|
| 567 | 554 | |
|---|
| 568 | | - ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma); |
|---|
| 555 | + ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE, &ring_dma, |
|---|
| 556 | + GFP_KERNEL); |
|---|
| 569 | 557 | if (!ring_space) { |
|---|
| 570 | 558 | err = -ENOMEM; |
|---|
| 571 | 559 | goto err_out_free_rx; |
|---|
| .. | .. |
|---|
| 670 | 658 | return 0; |
|---|
| 671 | 659 | |
|---|
| 672 | 660 | err_out_free_tx: |
|---|
| 673 | | - pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma); |
|---|
| 661 | + dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, |
|---|
| 662 | + np->tx_ring_dma); |
|---|
| 674 | 663 | err_out_free_rx: |
|---|
| 675 | | - pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma); |
|---|
| 664 | + dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, |
|---|
| 665 | + np->rx_ring_dma); |
|---|
| 676 | 666 | err_out_free_dev: |
|---|
| 677 | 667 | free_netdev(dev); |
|---|
| 678 | 668 | err_out_unmap: |
|---|
| .. | .. |
|---|
| 690 | 680 | if (dev) { |
|---|
| 691 | 681 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 692 | 682 | |
|---|
| 693 | | - pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, |
|---|
| 694 | | - np->tx_ring_dma); |
|---|
| 695 | | - pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, |
|---|
| 696 | | - np->rx_ring_dma); |
|---|
| 683 | + dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, |
|---|
| 684 | + np->tx_ring_dma); |
|---|
| 685 | + dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, |
|---|
| 686 | + np->rx_ring_dma); |
|---|
| 697 | 687 | unregister_netdev(dev); |
|---|
| 698 | 688 | pci_iounmap(pdev, np->mem); |
|---|
| 699 | 689 | free_netdev(dev); |
|---|
| .. | .. |
|---|
| 1070 | 1060 | np->lack_rxbuf = np->lack_rxbuf->next_desc_logical; |
|---|
| 1071 | 1061 | |
|---|
| 1072 | 1062 | np->lack_rxbuf->skbuff = skb; |
|---|
| 1073 | | - np->lack_rxbuf->buffer = pci_map_single(np->pci_dev, skb->data, |
|---|
| 1074 | | - np->rx_buf_sz, PCI_DMA_FROMDEVICE); |
|---|
| 1063 | + np->lack_rxbuf->buffer = dma_map_single(&np->pci_dev->dev, |
|---|
| 1064 | + skb->data, |
|---|
| 1065 | + np->rx_buf_sz, |
|---|
| 1066 | + DMA_FROM_DEVICE); |
|---|
| 1075 | 1067 | np->lack_rxbuf->status = RXOWN; |
|---|
| 1076 | 1068 | ++np->really_rx_count; |
|---|
| 1077 | 1069 | } |
|---|
| .. | .. |
|---|
| 1191 | 1183 | } |
|---|
| 1192 | 1184 | |
|---|
| 1193 | 1185 | |
|---|
| 1194 | | -static void fealnx_tx_timeout(struct net_device *dev) |
|---|
| 1186 | +static void fealnx_tx_timeout(struct net_device *dev, unsigned int txqueue) |
|---|
| 1195 | 1187 | { |
|---|
| 1196 | 1188 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 1197 | 1189 | void __iomem *ioaddr = np->mem; |
|---|
| .. | .. |
|---|
| 1265 | 1257 | |
|---|
| 1266 | 1258 | ++np->really_rx_count; |
|---|
| 1267 | 1259 | np->rx_ring[i].skbuff = skb; |
|---|
| 1268 | | - np->rx_ring[i].buffer = pci_map_single(np->pci_dev, skb->data, |
|---|
| 1269 | | - np->rx_buf_sz, PCI_DMA_FROMDEVICE); |
|---|
| 1260 | + np->rx_ring[i].buffer = dma_map_single(&np->pci_dev->dev, |
|---|
| 1261 | + skb->data, |
|---|
| 1262 | + np->rx_buf_sz, |
|---|
| 1263 | + DMA_FROM_DEVICE); |
|---|
| 1270 | 1264 | np->rx_ring[i].status = RXOWN; |
|---|
| 1271 | 1265 | np->rx_ring[i].control |= RXIC; |
|---|
| 1272 | 1266 | } |
|---|
| .. | .. |
|---|
| 1304 | 1298 | #define one_buffer |
|---|
| 1305 | 1299 | #define BPT 1022 |
|---|
| 1306 | 1300 | #if defined(one_buffer) |
|---|
| 1307 | | - np->cur_tx_copy->buffer = pci_map_single(np->pci_dev, skb->data, |
|---|
| 1308 | | - skb->len, PCI_DMA_TODEVICE); |
|---|
| 1301 | + np->cur_tx_copy->buffer = dma_map_single(&np->pci_dev->dev, skb->data, |
|---|
| 1302 | + skb->len, DMA_TO_DEVICE); |
|---|
| 1309 | 1303 | np->cur_tx_copy->control = TXIC | TXLD | TXFD | CRCEnable | PADEnable; |
|---|
| 1310 | 1304 | np->cur_tx_copy->control |= (skb->len << PKTSShift); /* pkt size */ |
|---|
| 1311 | 1305 | np->cur_tx_copy->control |= (skb->len << TBSShift); /* buffer size */ |
|---|
| .. | .. |
|---|
| 1320 | 1314 | struct fealnx_desc *next; |
|---|
| 1321 | 1315 | |
|---|
| 1322 | 1316 | /* for the first descriptor */ |
|---|
| 1323 | | - np->cur_tx_copy->buffer = pci_map_single(np->pci_dev, skb->data, |
|---|
| 1324 | | - BPT, PCI_DMA_TODEVICE); |
|---|
| 1317 | + np->cur_tx_copy->buffer = dma_map_single(&np->pci_dev->dev, |
|---|
| 1318 | + skb->data, BPT, |
|---|
| 1319 | + DMA_TO_DEVICE); |
|---|
| 1325 | 1320 | np->cur_tx_copy->control = TXIC | TXFD | CRCEnable | PADEnable; |
|---|
| 1326 | 1321 | np->cur_tx_copy->control |= (skb->len << PKTSShift); /* pkt size */ |
|---|
| 1327 | 1322 | np->cur_tx_copy->control |= (BPT << TBSShift); /* buffer size */ |
|---|
| .. | .. |
|---|
| 1335 | 1330 | // 89/12/29 add, |
|---|
| 1336 | 1331 | if (np->pci_dev->device == 0x891) |
|---|
| 1337 | 1332 | np->cur_tx_copy->control |= ETIControl | RetryTxLC; |
|---|
| 1338 | | - next->buffer = pci_map_single(ep->pci_dev, skb->data + BPT, |
|---|
| 1339 | | - skb->len - BPT, PCI_DMA_TODEVICE); |
|---|
| 1333 | + next->buffer = dma_map_single(&ep->pci_dev->dev, |
|---|
| 1334 | + skb->data + BPT, skb->len - BPT, |
|---|
| 1335 | + DMA_TO_DEVICE); |
|---|
| 1340 | 1336 | |
|---|
| 1341 | 1337 | next->status = TXOWN; |
|---|
| 1342 | 1338 | np->cur_tx_copy->status = TXOWN; |
|---|
| .. | .. |
|---|
| 1344 | 1340 | np->cur_tx_copy = next->next_desc_logical; |
|---|
| 1345 | 1341 | np->free_tx_count -= 2; |
|---|
| 1346 | 1342 | } else { |
|---|
| 1347 | | - np->cur_tx_copy->buffer = pci_map_single(np->pci_dev, skb->data, |
|---|
| 1348 | | - skb->len, PCI_DMA_TODEVICE); |
|---|
| 1343 | + np->cur_tx_copy->buffer = dma_map_single(&np->pci_dev->dev, |
|---|
| 1344 | + skb->data, skb->len, |
|---|
| 1345 | + DMA_TO_DEVICE); |
|---|
| 1349 | 1346 | np->cur_tx_copy->control = TXIC | TXLD | TXFD | CRCEnable | PADEnable; |
|---|
| 1350 | 1347 | np->cur_tx_copy->control |= (skb->len << PKTSShift); /* pkt size */ |
|---|
| 1351 | 1348 | np->cur_tx_copy->control |= (skb->len << TBSShift); /* buffer size */ |
|---|
| .. | .. |
|---|
| 1385 | 1382 | for (i = 0; i < TX_RING_SIZE; i++) { |
|---|
| 1386 | 1383 | cur = &np->tx_ring[i]; |
|---|
| 1387 | 1384 | if (cur->skbuff) { |
|---|
| 1388 | | - pci_unmap_single(np->pci_dev, cur->buffer, |
|---|
| 1389 | | - cur->skbuff->len, PCI_DMA_TODEVICE); |
|---|
| 1385 | + dma_unmap_single(&np->pci_dev->dev, cur->buffer, |
|---|
| 1386 | + cur->skbuff->len, DMA_TO_DEVICE); |
|---|
| 1390 | 1387 | dev_kfree_skb_any(cur->skbuff); |
|---|
| 1391 | 1388 | cur->skbuff = NULL; |
|---|
| 1392 | 1389 | } |
|---|
| .. | .. |
|---|
| 1529 | 1526 | } |
|---|
| 1530 | 1527 | |
|---|
| 1531 | 1528 | /* Free the original skb. */ |
|---|
| 1532 | | - pci_unmap_single(np->pci_dev, np->cur_tx->buffer, |
|---|
| 1533 | | - np->cur_tx->skbuff->len, PCI_DMA_TODEVICE); |
|---|
| 1534 | | - dev_kfree_skb_irq(np->cur_tx->skbuff); |
|---|
| 1529 | + dma_unmap_single(&np->pci_dev->dev, |
|---|
| 1530 | + np->cur_tx->buffer, |
|---|
| 1531 | + np->cur_tx->skbuff->len, |
|---|
| 1532 | + DMA_TO_DEVICE); |
|---|
| 1533 | + dev_consume_skb_irq(np->cur_tx->skbuff); |
|---|
| 1535 | 1534 | np->cur_tx->skbuff = NULL; |
|---|
| 1536 | 1535 | --np->really_tx_count; |
|---|
| 1537 | 1536 | if (np->cur_tx->control & TXLD) { |
|---|
| .. | .. |
|---|
| 1696 | 1695 | if (pkt_len < rx_copybreak && |
|---|
| 1697 | 1696 | (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { |
|---|
| 1698 | 1697 | skb_reserve(skb, 2); /* 16 byte align the IP header */ |
|---|
| 1699 | | - pci_dma_sync_single_for_cpu(np->pci_dev, |
|---|
| 1700 | | - np->cur_rx->buffer, |
|---|
| 1701 | | - np->rx_buf_sz, |
|---|
| 1702 | | - PCI_DMA_FROMDEVICE); |
|---|
| 1698 | + dma_sync_single_for_cpu(&np->pci_dev->dev, |
|---|
| 1699 | + np->cur_rx->buffer, |
|---|
| 1700 | + np->rx_buf_sz, |
|---|
| 1701 | + DMA_FROM_DEVICE); |
|---|
| 1703 | 1702 | /* Call copy + cksum if available. */ |
|---|
| 1704 | 1703 | |
|---|
| 1705 | 1704 | #if ! defined(__alpha__) |
|---|
| .. | .. |
|---|
| 1710 | 1709 | skb_put_data(skb, np->cur_rx->skbuff->data, |
|---|
| 1711 | 1710 | pkt_len); |
|---|
| 1712 | 1711 | #endif |
|---|
| 1713 | | - pci_dma_sync_single_for_device(np->pci_dev, |
|---|
| 1714 | | - np->cur_rx->buffer, |
|---|
| 1715 | | - np->rx_buf_sz, |
|---|
| 1716 | | - PCI_DMA_FROMDEVICE); |
|---|
| 1712 | + dma_sync_single_for_device(&np->pci_dev->dev, |
|---|
| 1713 | + np->cur_rx->buffer, |
|---|
| 1714 | + np->rx_buf_sz, |
|---|
| 1715 | + DMA_FROM_DEVICE); |
|---|
| 1717 | 1716 | } else { |
|---|
| 1718 | | - pci_unmap_single(np->pci_dev, |
|---|
| 1717 | + dma_unmap_single(&np->pci_dev->dev, |
|---|
| 1719 | 1718 | np->cur_rx->buffer, |
|---|
| 1720 | 1719 | np->rx_buf_sz, |
|---|
| 1721 | | - PCI_DMA_FROMDEVICE); |
|---|
| 1720 | + DMA_FROM_DEVICE); |
|---|
| 1722 | 1721 | skb_put(skb = np->cur_rx->skbuff, pkt_len); |
|---|
| 1723 | 1722 | np->cur_rx->skbuff = NULL; |
|---|
| 1724 | 1723 | --np->really_rx_count; |
|---|
| .. | .. |
|---|
| 1809 | 1808 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 1810 | 1809 | |
|---|
| 1811 | 1810 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
|---|
| 1812 | | - strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
|---|
| 1813 | 1811 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
|---|
| 1814 | 1812 | } |
|---|
| 1815 | 1813 | |
|---|
| .. | .. |
|---|
| 1911 | 1909 | |
|---|
| 1912 | 1910 | np->rx_ring[i].status = 0; |
|---|
| 1913 | 1911 | if (skb) { |
|---|
| 1914 | | - pci_unmap_single(np->pci_dev, np->rx_ring[i].buffer, |
|---|
| 1915 | | - np->rx_buf_sz, PCI_DMA_FROMDEVICE); |
|---|
| 1912 | + dma_unmap_single(&np->pci_dev->dev, |
|---|
| 1913 | + np->rx_ring[i].buffer, np->rx_buf_sz, |
|---|
| 1914 | + DMA_FROM_DEVICE); |
|---|
| 1916 | 1915 | dev_kfree_skb(skb); |
|---|
| 1917 | 1916 | np->rx_ring[i].skbuff = NULL; |
|---|
| 1918 | 1917 | } |
|---|
| .. | .. |
|---|
| 1922 | 1921 | struct sk_buff *skb = np->tx_ring[i].skbuff; |
|---|
| 1923 | 1922 | |
|---|
| 1924 | 1923 | if (skb) { |
|---|
| 1925 | | - pci_unmap_single(np->pci_dev, np->tx_ring[i].buffer, |
|---|
| 1926 | | - skb->len, PCI_DMA_TODEVICE); |
|---|
| 1924 | + dma_unmap_single(&np->pci_dev->dev, |
|---|
| 1925 | + np->tx_ring[i].buffer, skb->len, |
|---|
| 1926 | + DMA_TO_DEVICE); |
|---|
| 1927 | 1927 | dev_kfree_skb(skb); |
|---|
| 1928 | 1928 | np->tx_ring[i].skbuff = NULL; |
|---|
| 1929 | 1929 | } |
|---|
| .. | .. |
|---|
| 1950 | 1950 | |
|---|
| 1951 | 1951 | static int __init fealnx_init(void) |
|---|
| 1952 | 1952 | { |
|---|
| 1953 | | -/* when a module, this is printed whether or not devices are found in probe */ |
|---|
| 1954 | | -#ifdef MODULE |
|---|
| 1955 | | - printk(version); |
|---|
| 1956 | | -#endif |
|---|
| 1957 | | - |
|---|
| 1958 | 1953 | return pci_register_driver(&fealnx_driver); |
|---|
| 1959 | 1954 | } |
|---|
| 1960 | 1955 | |
|---|