.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * acenic.c: Linux driver for the Alteon AceNIC Gigabit Ethernet card |
---|
3 | 4 | * and other Tigon based cards. |
---|
.. | .. |
---|
11 | 12 | * setup, please subscribe to the lists if you have any questions |
---|
12 | 13 | * about the driver. Send mail to linux-acenic-help@sunsite.auc.dk to |
---|
13 | 14 | * see how to subscribe. |
---|
14 | | - * |
---|
15 | | - * This program is free software; you can redistribute it and/or modify |
---|
16 | | - * it under the terms of the GNU General Public License as published by |
---|
17 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
18 | | - * (at your option) any later version. |
---|
19 | 15 | * |
---|
20 | 16 | * Additional credits: |
---|
21 | 17 | * Pete Wyckoff <wyckoff@ca.sandia.gov>: Initial Linux/Alpha and trace |
---|
.. | .. |
---|
441 | 437 | .set_link_ksettings = ace_set_link_ksettings, |
---|
442 | 438 | }; |
---|
443 | 439 | |
---|
444 | | -static void ace_watchdog(struct net_device *dev); |
---|
| 440 | +static void ace_watchdog(struct net_device *dev, unsigned int txqueue); |
---|
445 | 441 | |
---|
446 | 442 | static const struct net_device_ops ace_netdev_ops = { |
---|
447 | 443 | .ndo_open = ace_open, |
---|
.. | .. |
---|
469 | 465 | SET_NETDEV_DEV(dev, &pdev->dev); |
---|
470 | 466 | |
---|
471 | 467 | ap = netdev_priv(dev); |
---|
| 468 | + ap->ndev = dev; |
---|
472 | 469 | ap->pdev = pdev; |
---|
473 | 470 | ap->name = pci_name(pdev); |
---|
474 | 471 | |
---|
.. | .. |
---|
551 | 548 | ap->name); |
---|
552 | 549 | break; |
---|
553 | 550 | } |
---|
554 | | - /* Fall through */ |
---|
| 551 | + fallthrough; |
---|
555 | 552 | case PCI_VENDOR_ID_SGI: |
---|
556 | 553 | printk(KERN_INFO "%s: SGI AceNIC ", ap->name); |
---|
557 | 554 | break; |
---|
.. | .. |
---|
646 | 643 | |
---|
647 | 644 | ringp = &ap->skb->rx_std_skbuff[i]; |
---|
648 | 645 | mapping = dma_unmap_addr(ringp, mapping); |
---|
649 | | - pci_unmap_page(ap->pdev, mapping, |
---|
650 | | - ACE_STD_BUFSIZE, |
---|
651 | | - PCI_DMA_FROMDEVICE); |
---|
| 646 | + dma_unmap_page(&ap->pdev->dev, mapping, |
---|
| 647 | + ACE_STD_BUFSIZE, DMA_FROM_DEVICE); |
---|
652 | 648 | |
---|
653 | 649 | ap->rx_std_ring[i].size = 0; |
---|
654 | 650 | ap->skb->rx_std_skbuff[i].skb = NULL; |
---|
.. | .. |
---|
666 | 662 | |
---|
667 | 663 | ringp = &ap->skb->rx_mini_skbuff[i]; |
---|
668 | 664 | mapping = dma_unmap_addr(ringp,mapping); |
---|
669 | | - pci_unmap_page(ap->pdev, mapping, |
---|
| 665 | + dma_unmap_page(&ap->pdev->dev, mapping, |
---|
670 | 666 | ACE_MINI_BUFSIZE, |
---|
671 | | - PCI_DMA_FROMDEVICE); |
---|
| 667 | + DMA_FROM_DEVICE); |
---|
672 | 668 | |
---|
673 | 669 | ap->rx_mini_ring[i].size = 0; |
---|
674 | 670 | ap->skb->rx_mini_skbuff[i].skb = NULL; |
---|
.. | .. |
---|
685 | 681 | |
---|
686 | 682 | ringp = &ap->skb->rx_jumbo_skbuff[i]; |
---|
687 | 683 | mapping = dma_unmap_addr(ringp, mapping); |
---|
688 | | - pci_unmap_page(ap->pdev, mapping, |
---|
689 | | - ACE_JUMBO_BUFSIZE, |
---|
690 | | - PCI_DMA_FROMDEVICE); |
---|
| 684 | + dma_unmap_page(&ap->pdev->dev, mapping, |
---|
| 685 | + ACE_JUMBO_BUFSIZE, DMA_FROM_DEVICE); |
---|
691 | 686 | |
---|
692 | 687 | ap->rx_jumbo_ring[i].size = 0; |
---|
693 | 688 | ap->skb->rx_jumbo_skbuff[i].skb = NULL; |
---|
.. | .. |
---|
717 | 712 | RX_JUMBO_RING_ENTRIES + |
---|
718 | 713 | RX_MINI_RING_ENTRIES + |
---|
719 | 714 | RX_RETURN_RING_ENTRIES)); |
---|
720 | | - pci_free_consistent(ap->pdev, size, ap->rx_std_ring, |
---|
721 | | - ap->rx_ring_base_dma); |
---|
| 715 | + dma_free_coherent(&ap->pdev->dev, size, ap->rx_std_ring, |
---|
| 716 | + ap->rx_ring_base_dma); |
---|
722 | 717 | ap->rx_std_ring = NULL; |
---|
723 | 718 | ap->rx_jumbo_ring = NULL; |
---|
724 | 719 | ap->rx_mini_ring = NULL; |
---|
.. | .. |
---|
726 | 721 | } |
---|
727 | 722 | if (ap->evt_ring != NULL) { |
---|
728 | 723 | size = (sizeof(struct event) * EVT_RING_ENTRIES); |
---|
729 | | - pci_free_consistent(ap->pdev, size, ap->evt_ring, |
---|
730 | | - ap->evt_ring_dma); |
---|
| 724 | + dma_free_coherent(&ap->pdev->dev, size, ap->evt_ring, |
---|
| 725 | + ap->evt_ring_dma); |
---|
731 | 726 | ap->evt_ring = NULL; |
---|
732 | 727 | } |
---|
733 | 728 | if (ap->tx_ring != NULL && !ACE_IS_TIGON_I(ap)) { |
---|
734 | 729 | size = (sizeof(struct tx_desc) * MAX_TX_RING_ENTRIES); |
---|
735 | | - pci_free_consistent(ap->pdev, size, ap->tx_ring, |
---|
736 | | - ap->tx_ring_dma); |
---|
| 730 | + dma_free_coherent(&ap->pdev->dev, size, ap->tx_ring, |
---|
| 731 | + ap->tx_ring_dma); |
---|
737 | 732 | } |
---|
738 | 733 | ap->tx_ring = NULL; |
---|
739 | 734 | |
---|
740 | 735 | if (ap->evt_prd != NULL) { |
---|
741 | | - pci_free_consistent(ap->pdev, sizeof(u32), |
---|
742 | | - (void *)ap->evt_prd, ap->evt_prd_dma); |
---|
| 736 | + dma_free_coherent(&ap->pdev->dev, sizeof(u32), |
---|
| 737 | + (void *)ap->evt_prd, ap->evt_prd_dma); |
---|
743 | 738 | ap->evt_prd = NULL; |
---|
744 | 739 | } |
---|
745 | 740 | if (ap->rx_ret_prd != NULL) { |
---|
746 | | - pci_free_consistent(ap->pdev, sizeof(u32), |
---|
747 | | - (void *)ap->rx_ret_prd, |
---|
748 | | - ap->rx_ret_prd_dma); |
---|
| 741 | + dma_free_coherent(&ap->pdev->dev, sizeof(u32), |
---|
| 742 | + (void *)ap->rx_ret_prd, ap->rx_ret_prd_dma); |
---|
749 | 743 | ap->rx_ret_prd = NULL; |
---|
750 | 744 | } |
---|
751 | 745 | if (ap->tx_csm != NULL) { |
---|
752 | | - pci_free_consistent(ap->pdev, sizeof(u32), |
---|
753 | | - (void *)ap->tx_csm, ap->tx_csm_dma); |
---|
| 746 | + dma_free_coherent(&ap->pdev->dev, sizeof(u32), |
---|
| 747 | + (void *)ap->tx_csm, ap->tx_csm_dma); |
---|
754 | 748 | ap->tx_csm = NULL; |
---|
755 | 749 | } |
---|
756 | 750 | } |
---|
.. | .. |
---|
767 | 761 | RX_MINI_RING_ENTRIES + |
---|
768 | 762 | RX_RETURN_RING_ENTRIES)); |
---|
769 | 763 | |
---|
770 | | - ap->rx_std_ring = pci_alloc_consistent(ap->pdev, size, |
---|
771 | | - &ap->rx_ring_base_dma); |
---|
| 764 | + ap->rx_std_ring = dma_alloc_coherent(&ap->pdev->dev, size, |
---|
| 765 | + &ap->rx_ring_base_dma, GFP_KERNEL); |
---|
772 | 766 | if (ap->rx_std_ring == NULL) |
---|
773 | 767 | goto fail; |
---|
774 | 768 | |
---|
.. | .. |
---|
778 | 772 | |
---|
779 | 773 | size = (sizeof(struct event) * EVT_RING_ENTRIES); |
---|
780 | 774 | |
---|
781 | | - ap->evt_ring = pci_alloc_consistent(ap->pdev, size, &ap->evt_ring_dma); |
---|
| 775 | + ap->evt_ring = dma_alloc_coherent(&ap->pdev->dev, size, |
---|
| 776 | + &ap->evt_ring_dma, GFP_KERNEL); |
---|
782 | 777 | |
---|
783 | 778 | if (ap->evt_ring == NULL) |
---|
784 | 779 | goto fail; |
---|
.. | .. |
---|
790 | 785 | if (!ACE_IS_TIGON_I(ap)) { |
---|
791 | 786 | size = (sizeof(struct tx_desc) * MAX_TX_RING_ENTRIES); |
---|
792 | 787 | |
---|
793 | | - ap->tx_ring = pci_alloc_consistent(ap->pdev, size, |
---|
794 | | - &ap->tx_ring_dma); |
---|
| 788 | + ap->tx_ring = dma_alloc_coherent(&ap->pdev->dev, size, |
---|
| 789 | + &ap->tx_ring_dma, GFP_KERNEL); |
---|
795 | 790 | |
---|
796 | 791 | if (ap->tx_ring == NULL) |
---|
797 | 792 | goto fail; |
---|
798 | 793 | } |
---|
799 | 794 | |
---|
800 | | - ap->evt_prd = pci_alloc_consistent(ap->pdev, sizeof(u32), |
---|
801 | | - &ap->evt_prd_dma); |
---|
| 795 | + ap->evt_prd = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32), |
---|
| 796 | + &ap->evt_prd_dma, GFP_KERNEL); |
---|
802 | 797 | if (ap->evt_prd == NULL) |
---|
803 | 798 | goto fail; |
---|
804 | 799 | |
---|
805 | | - ap->rx_ret_prd = pci_alloc_consistent(ap->pdev, sizeof(u32), |
---|
806 | | - &ap->rx_ret_prd_dma); |
---|
| 800 | + ap->rx_ret_prd = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32), |
---|
| 801 | + &ap->rx_ret_prd_dma, GFP_KERNEL); |
---|
807 | 802 | if (ap->rx_ret_prd == NULL) |
---|
808 | 803 | goto fail; |
---|
809 | 804 | |
---|
810 | | - ap->tx_csm = pci_alloc_consistent(ap->pdev, sizeof(u32), |
---|
811 | | - &ap->tx_csm_dma); |
---|
| 805 | + ap->tx_csm = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32), |
---|
| 806 | + &ap->tx_csm_dma, GFP_KERNEL); |
---|
812 | 807 | if (ap->tx_csm == NULL) |
---|
813 | 808 | goto fail; |
---|
814 | 809 | |
---|
.. | .. |
---|
834 | 829 | ace_free_descriptors(dev); |
---|
835 | 830 | |
---|
836 | 831 | if (ap->info) |
---|
837 | | - pci_free_consistent(ap->pdev, sizeof(struct ace_info), |
---|
838 | | - ap->info, ap->info_dma); |
---|
| 832 | + dma_free_coherent(&ap->pdev->dev, sizeof(struct ace_info), |
---|
| 833 | + ap->info, ap->info_dma); |
---|
839 | 834 | kfree(ap->skb); |
---|
840 | 835 | kfree(ap->trace_buf); |
---|
841 | 836 | |
---|
.. | .. |
---|
1133 | 1128 | /* |
---|
1134 | 1129 | * Configure DMA attributes. |
---|
1135 | 1130 | */ |
---|
1136 | | - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { |
---|
| 1131 | + if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { |
---|
1137 | 1132 | ap->pci_using_dac = 1; |
---|
1138 | | - } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { |
---|
| 1133 | + } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { |
---|
1139 | 1134 | ap->pci_using_dac = 0; |
---|
1140 | 1135 | } else { |
---|
1141 | 1136 | ecode = -ENODEV; |
---|
.. | .. |
---|
1147 | 1142 | * and the control blocks for the transmit and receive rings |
---|
1148 | 1143 | * as they need to be setup once and for all. |
---|
1149 | 1144 | */ |
---|
1150 | | - if (!(info = pci_alloc_consistent(ap->pdev, sizeof(struct ace_info), |
---|
1151 | | - &ap->info_dma))) { |
---|
| 1145 | + if (!(info = dma_alloc_coherent(&ap->pdev->dev, sizeof(struct ace_info), |
---|
| 1146 | + &ap->info_dma, GFP_KERNEL))) { |
---|
1152 | 1147 | ecode = -EAGAIN; |
---|
1153 | 1148 | goto init_error; |
---|
1154 | 1149 | } |
---|
.. | .. |
---|
1157 | 1152 | /* |
---|
1158 | 1153 | * Get the memory for the skb rings. |
---|
1159 | 1154 | */ |
---|
1160 | | - if (!(ap->skb = kmalloc(sizeof(struct ace_skb), GFP_KERNEL))) { |
---|
| 1155 | + if (!(ap->skb = kzalloc(sizeof(struct ace_skb), GFP_KERNEL))) { |
---|
1161 | 1156 | ecode = -EAGAIN; |
---|
1162 | 1157 | goto init_error; |
---|
1163 | 1158 | } |
---|
.. | .. |
---|
1177 | 1172 | ap->last_std_rx = 0; |
---|
1178 | 1173 | ap->last_mini_rx = 0; |
---|
1179 | 1174 | #endif |
---|
1180 | | - |
---|
1181 | | - memset(ap->info, 0, sizeof(struct ace_info)); |
---|
1182 | | - memset(ap->skb, 0, sizeof(struct ace_skb)); |
---|
1183 | 1175 | |
---|
1184 | 1176 | ecode = ace_load_firmware(dev); |
---|
1185 | 1177 | if (ecode) |
---|
.. | .. |
---|
1546 | 1538 | } |
---|
1547 | 1539 | |
---|
1548 | 1540 | |
---|
1549 | | -static void ace_watchdog(struct net_device *data) |
---|
| 1541 | +static void ace_watchdog(struct net_device *data, unsigned int txqueue) |
---|
1550 | 1542 | { |
---|
1551 | 1543 | struct net_device *dev = data; |
---|
1552 | 1544 | struct ace_private *ap = netdev_priv(dev); |
---|
.. | .. |
---|
1571 | 1563 | } |
---|
1572 | 1564 | |
---|
1573 | 1565 | |
---|
1574 | | -static void ace_tasklet(unsigned long arg) |
---|
| 1566 | +static void ace_tasklet(struct tasklet_struct *t) |
---|
1575 | 1567 | { |
---|
1576 | | - struct net_device *dev = (struct net_device *) arg; |
---|
1577 | | - struct ace_private *ap = netdev_priv(dev); |
---|
| 1568 | + struct ace_private *ap = from_tasklet(ap, t, ace_tasklet); |
---|
| 1569 | + struct net_device *dev = ap->ndev; |
---|
1578 | 1570 | int cur_size; |
---|
1579 | 1571 | |
---|
1580 | 1572 | cur_size = atomic_read(&ap->cur_rx_bufs); |
---|
.. | .. |
---|
1650 | 1642 | if (!skb) |
---|
1651 | 1643 | break; |
---|
1652 | 1644 | |
---|
1653 | | - mapping = pci_map_page(ap->pdev, virt_to_page(skb->data), |
---|
| 1645 | + mapping = dma_map_page(&ap->pdev->dev, |
---|
| 1646 | + virt_to_page(skb->data), |
---|
1654 | 1647 | offset_in_page(skb->data), |
---|
1655 | | - ACE_STD_BUFSIZE, |
---|
1656 | | - PCI_DMA_FROMDEVICE); |
---|
| 1648 | + ACE_STD_BUFSIZE, DMA_FROM_DEVICE); |
---|
1657 | 1649 | ap->skb->rx_std_skbuff[idx].skb = skb; |
---|
1658 | 1650 | dma_unmap_addr_set(&ap->skb->rx_std_skbuff[idx], |
---|
1659 | 1651 | mapping, mapping); |
---|
.. | .. |
---|
1711 | 1703 | if (!skb) |
---|
1712 | 1704 | break; |
---|
1713 | 1705 | |
---|
1714 | | - mapping = pci_map_page(ap->pdev, virt_to_page(skb->data), |
---|
| 1706 | + mapping = dma_map_page(&ap->pdev->dev, |
---|
| 1707 | + virt_to_page(skb->data), |
---|
1715 | 1708 | offset_in_page(skb->data), |
---|
1716 | | - ACE_MINI_BUFSIZE, |
---|
1717 | | - PCI_DMA_FROMDEVICE); |
---|
| 1709 | + ACE_MINI_BUFSIZE, DMA_FROM_DEVICE); |
---|
1718 | 1710 | ap->skb->rx_mini_skbuff[idx].skb = skb; |
---|
1719 | 1711 | dma_unmap_addr_set(&ap->skb->rx_mini_skbuff[idx], |
---|
1720 | 1712 | mapping, mapping); |
---|
.. | .. |
---|
1767 | 1759 | if (!skb) |
---|
1768 | 1760 | break; |
---|
1769 | 1761 | |
---|
1770 | | - mapping = pci_map_page(ap->pdev, virt_to_page(skb->data), |
---|
| 1762 | + mapping = dma_map_page(&ap->pdev->dev, |
---|
| 1763 | + virt_to_page(skb->data), |
---|
1771 | 1764 | offset_in_page(skb->data), |
---|
1772 | | - ACE_JUMBO_BUFSIZE, |
---|
1773 | | - PCI_DMA_FROMDEVICE); |
---|
| 1765 | + ACE_JUMBO_BUFSIZE, DMA_FROM_DEVICE); |
---|
1774 | 1766 | ap->skb->rx_jumbo_skbuff[idx].skb = skb; |
---|
1775 | 1767 | dma_unmap_addr_set(&ap->skb->rx_jumbo_skbuff[idx], |
---|
1776 | 1768 | mapping, mapping); |
---|
.. | .. |
---|
1981 | 1973 | |
---|
1982 | 1974 | skb = rip->skb; |
---|
1983 | 1975 | rip->skb = NULL; |
---|
1984 | | - pci_unmap_page(ap->pdev, |
---|
1985 | | - dma_unmap_addr(rip, mapping), |
---|
1986 | | - mapsize, |
---|
1987 | | - PCI_DMA_FROMDEVICE); |
---|
| 1976 | + dma_unmap_page(&ap->pdev->dev, dma_unmap_addr(rip, mapping), |
---|
| 1977 | + mapsize, DMA_FROM_DEVICE); |
---|
1988 | 1978 | skb_put(skb, retdesc->size); |
---|
1989 | 1979 | |
---|
1990 | 1980 | /* |
---|
.. | .. |
---|
2050 | 2040 | skb = info->skb; |
---|
2051 | 2041 | |
---|
2052 | 2042 | if (dma_unmap_len(info, maplen)) { |
---|
2053 | | - pci_unmap_page(ap->pdev, dma_unmap_addr(info, mapping), |
---|
| 2043 | + dma_unmap_page(&ap->pdev->dev, |
---|
| 2044 | + dma_unmap_addr(info, mapping), |
---|
2054 | 2045 | dma_unmap_len(info, maplen), |
---|
2055 | | - PCI_DMA_TODEVICE); |
---|
| 2046 | + DMA_TO_DEVICE); |
---|
2056 | 2047 | dma_unmap_len_set(info, maplen, 0); |
---|
2057 | 2048 | } |
---|
2058 | 2049 | |
---|
2059 | 2050 | if (skb) { |
---|
2060 | 2051 | dev->stats.tx_packets++; |
---|
2061 | 2052 | dev->stats.tx_bytes += skb->len; |
---|
2062 | | - dev_kfree_skb_irq(skb); |
---|
| 2053 | + dev_consume_skb_irq(skb); |
---|
2063 | 2054 | info->skb = NULL; |
---|
2064 | 2055 | } |
---|
2065 | 2056 | |
---|
.. | .. |
---|
2279 | 2270 | /* |
---|
2280 | 2271 | * Setup the bottom half rx ring refill handler |
---|
2281 | 2272 | */ |
---|
2282 | | - tasklet_init(&ap->ace_tasklet, ace_tasklet, (unsigned long)dev); |
---|
| 2273 | + tasklet_setup(&ap->ace_tasklet, ace_tasklet); |
---|
2283 | 2274 | return 0; |
---|
2284 | 2275 | } |
---|
2285 | 2276 | |
---|
.. | .. |
---|
2341 | 2332 | } else |
---|
2342 | 2333 | memset(ap->tx_ring + i, 0, |
---|
2343 | 2334 | sizeof(struct tx_desc)); |
---|
2344 | | - pci_unmap_page(ap->pdev, dma_unmap_addr(info, mapping), |
---|
| 2335 | + dma_unmap_page(&ap->pdev->dev, |
---|
| 2336 | + dma_unmap_addr(info, mapping), |
---|
2345 | 2337 | dma_unmap_len(info, maplen), |
---|
2346 | | - PCI_DMA_TODEVICE); |
---|
| 2338 | + DMA_TO_DEVICE); |
---|
2347 | 2339 | dma_unmap_len_set(info, maplen, 0); |
---|
2348 | 2340 | } |
---|
2349 | 2341 | if (skb) { |
---|
.. | .. |
---|
2373 | 2365 | dma_addr_t mapping; |
---|
2374 | 2366 | struct tx_ring_info *info; |
---|
2375 | 2367 | |
---|
2376 | | - mapping = pci_map_page(ap->pdev, virt_to_page(skb->data), |
---|
2377 | | - offset_in_page(skb->data), |
---|
2378 | | - skb->len, PCI_DMA_TODEVICE); |
---|
| 2368 | + mapping = dma_map_page(&ap->pdev->dev, virt_to_page(skb->data), |
---|
| 2369 | + offset_in_page(skb->data), skb->len, |
---|
| 2370 | + DMA_TO_DEVICE); |
---|
2379 | 2371 | |
---|
2380 | 2372 | info = ap->skb->tx_skbuff + idx; |
---|
2381 | 2373 | info->skb = tail; |
---|
.. | .. |
---|
2703 | 2695 | struct ace_private *ap = netdev_priv(dev); |
---|
2704 | 2696 | |
---|
2705 | 2697 | strlcpy(info->driver, "acenic", sizeof(info->driver)); |
---|
2706 | | - snprintf(info->version, sizeof(info->version), "%i.%i.%i", |
---|
2707 | | - ap->firmware_major, ap->firmware_minor, |
---|
2708 | | - ap->firmware_fix); |
---|
| 2698 | + snprintf(info->fw_version, sizeof(info->version), "%i.%i.%i", |
---|
| 2699 | + ap->firmware_major, ap->firmware_minor, ap->firmware_fix); |
---|
2709 | 2700 | |
---|
2710 | 2701 | if (ap->pdev) |
---|
2711 | 2702 | strlcpy(info->bus_info, pci_name(ap->pdev), |
---|