.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright(c) 2007 Atheros Corporation. All rights reserved. |
---|
3 | 4 | * |
---|
4 | 5 | * Derived from Intel e1000 driver |
---|
5 | 6 | * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify it |
---|
8 | | - * under the terms of the GNU General Public License as published by the Free |
---|
9 | | - * Software Foundation; either version 2 of the License, or (at your option) |
---|
10 | | - * any later version. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
---|
13 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
14 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
15 | | - * more details. |
---|
16 | | - * |
---|
17 | | - * You should have received a copy of the GNU General Public License along with |
---|
18 | | - * this program; if not, write to the Free Software Foundation, Inc., 59 |
---|
19 | | - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
20 | 7 | */ |
---|
21 | 8 | |
---|
22 | 9 | #include "atl1e.h" |
---|
23 | 10 | |
---|
24 | | -#define DRV_VERSION "1.0.0.7-NAPI" |
---|
25 | | - |
---|
26 | 11 | char atl1e_driver_name[] = "ATL1E"; |
---|
27 | | -char atl1e_driver_version[] = DRV_VERSION; |
---|
28 | 12 | #define PCI_DEVICE_ID_ATTANSIC_L1E 0x1026 |
---|
29 | 13 | /* |
---|
30 | 14 | * atl1e_pci_tbl - PCI Device ID Table |
---|
.. | .. |
---|
46 | 30 | MODULE_AUTHOR("Atheros Corporation, <xiong.huang@atheros.com>, Jie Yang <jie.yang@atheros.com>"); |
---|
47 | 31 | MODULE_DESCRIPTION("Atheros 1000M Ethernet Network Driver"); |
---|
48 | 32 | MODULE_LICENSE("GPL"); |
---|
49 | | -MODULE_VERSION(DRV_VERSION); |
---|
50 | 33 | |
---|
51 | 34 | static void atl1e_setup_mac_ctrl(struct atl1e_adapter *adapter); |
---|
52 | 35 | |
---|
.. | .. |
---|
128 | 111 | |
---|
129 | 112 | /** |
---|
130 | 113 | * atl1e_phy_config - Timer Call-back |
---|
131 | | - * @data: pointer to netdev cast into an unsigned long |
---|
| 114 | + * @t: timer list containing pointer to netdev cast into an unsigned long |
---|
132 | 115 | */ |
---|
133 | 116 | static void atl1e_phy_config(struct timer_list *t) |
---|
134 | 117 | { |
---|
.. | .. |
---|
144 | 127 | |
---|
145 | 128 | void atl1e_reinit_locked(struct atl1e_adapter *adapter) |
---|
146 | 129 | { |
---|
147 | | - |
---|
148 | | - WARN_ON(in_interrupt()); |
---|
149 | 130 | while (test_and_set_bit(__AT_RESETTING, &adapter->flags)) |
---|
150 | 131 | msleep(1); |
---|
151 | 132 | atl1e_down(adapter); |
---|
.. | .. |
---|
213 | 194 | |
---|
214 | 195 | /** |
---|
215 | 196 | * atl1e_link_chg_task - deal with link change event Out of interrupt context |
---|
216 | | - * @netdev: network interface device structure |
---|
| 197 | + * @work: work struct with driver info |
---|
217 | 198 | */ |
---|
218 | 199 | static void atl1e_link_chg_task(struct work_struct *work) |
---|
219 | 200 | { |
---|
.. | .. |
---|
263 | 244 | /** |
---|
264 | 245 | * atl1e_tx_timeout - Respond to a Tx Hang |
---|
265 | 246 | * @netdev: network interface device structure |
---|
| 247 | + * @txqueue: the index of the hanging queue |
---|
266 | 248 | */ |
---|
267 | | -static void atl1e_tx_timeout(struct net_device *netdev) |
---|
| 249 | +static void atl1e_tx_timeout(struct net_device *netdev, unsigned int txqueue) |
---|
268 | 250 | { |
---|
269 | 251 | struct atl1e_adapter *adapter = netdev_priv(netdev); |
---|
270 | 252 | |
---|
.. | .. |
---|
671 | 653 | tx_buffer = &tx_ring->tx_buffer[index]; |
---|
672 | 654 | if (tx_buffer->dma) { |
---|
673 | 655 | if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE) |
---|
674 | | - pci_unmap_single(pdev, tx_buffer->dma, |
---|
675 | | - tx_buffer->length, PCI_DMA_TODEVICE); |
---|
| 656 | + dma_unmap_single(&pdev->dev, tx_buffer->dma, |
---|
| 657 | + tx_buffer->length, |
---|
| 658 | + DMA_TO_DEVICE); |
---|
676 | 659 | else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE) |
---|
677 | | - pci_unmap_page(pdev, tx_buffer->dma, |
---|
678 | | - tx_buffer->length, PCI_DMA_TODEVICE); |
---|
| 660 | + dma_unmap_page(&pdev->dev, tx_buffer->dma, |
---|
| 661 | + tx_buffer->length, |
---|
| 662 | + DMA_TO_DEVICE); |
---|
679 | 663 | tx_buffer->dma = 0; |
---|
680 | 664 | } |
---|
681 | 665 | } |
---|
.. | .. |
---|
791 | 775 | atl1e_clean_rx_ring(adapter); |
---|
792 | 776 | |
---|
793 | 777 | if (adapter->ring_vir_addr) { |
---|
794 | | - pci_free_consistent(pdev, adapter->ring_size, |
---|
795 | | - adapter->ring_vir_addr, adapter->ring_dma); |
---|
| 778 | + dma_free_coherent(&pdev->dev, adapter->ring_size, |
---|
| 779 | + adapter->ring_vir_addr, adapter->ring_dma); |
---|
796 | 780 | adapter->ring_vir_addr = NULL; |
---|
797 | 781 | } |
---|
798 | 782 | |
---|
.. | .. |
---|
827 | 811 | /* real ring DMA buffer */ |
---|
828 | 812 | |
---|
829 | 813 | size = adapter->ring_size; |
---|
830 | | - adapter->ring_vir_addr = pci_zalloc_consistent(pdev, adapter->ring_size, |
---|
831 | | - &adapter->ring_dma); |
---|
| 814 | + adapter->ring_vir_addr = dma_alloc_coherent(&pdev->dev, |
---|
| 815 | + adapter->ring_size, |
---|
| 816 | + &adapter->ring_dma, GFP_KERNEL); |
---|
832 | 817 | if (adapter->ring_vir_addr == NULL) { |
---|
833 | 818 | netdev_err(adapter->netdev, |
---|
834 | | - "pci_alloc_consistent failed, size = D%d\n", size); |
---|
| 819 | + "dma_alloc_coherent failed, size = D%d\n", size); |
---|
835 | 820 | return -ENOMEM; |
---|
836 | 821 | } |
---|
837 | 822 | |
---|
.. | .. |
---|
887 | 872 | return 0; |
---|
888 | 873 | failed: |
---|
889 | 874 | if (adapter->ring_vir_addr != NULL) { |
---|
890 | | - pci_free_consistent(pdev, adapter->ring_size, |
---|
891 | | - adapter->ring_vir_addr, adapter->ring_dma); |
---|
| 875 | + dma_free_coherent(&pdev->dev, adapter->ring_size, |
---|
| 876 | + adapter->ring_vir_addr, adapter->ring_dma); |
---|
892 | 877 | adapter->ring_vir_addr = NULL; |
---|
893 | 878 | } |
---|
894 | 879 | return err; |
---|
.. | .. |
---|
1250 | 1235 | tx_buffer = &tx_ring->tx_buffer[next_to_clean]; |
---|
1251 | 1236 | if (tx_buffer->dma) { |
---|
1252 | 1237 | if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE) |
---|
1253 | | - pci_unmap_single(adapter->pdev, tx_buffer->dma, |
---|
1254 | | - tx_buffer->length, PCI_DMA_TODEVICE); |
---|
| 1238 | + dma_unmap_single(&adapter->pdev->dev, |
---|
| 1239 | + tx_buffer->dma, |
---|
| 1240 | + tx_buffer->length, |
---|
| 1241 | + DMA_TO_DEVICE); |
---|
1255 | 1242 | else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE) |
---|
1256 | | - pci_unmap_page(adapter->pdev, tx_buffer->dma, |
---|
1257 | | - tx_buffer->length, PCI_DMA_TODEVICE); |
---|
| 1243 | + dma_unmap_page(&adapter->pdev->dev, |
---|
| 1244 | + tx_buffer->dma, |
---|
| 1245 | + tx_buffer->length, |
---|
| 1246 | + DMA_TO_DEVICE); |
---|
1258 | 1247 | tx_buffer->dma = 0; |
---|
1259 | 1248 | } |
---|
1260 | 1249 | |
---|
1261 | 1250 | if (tx_buffer->skb) { |
---|
1262 | | - dev_kfree_skb_irq(tx_buffer->skb); |
---|
| 1251 | + dev_consume_skb_irq(tx_buffer->skb); |
---|
1263 | 1252 | tx_buffer->skb = NULL; |
---|
1264 | 1253 | } |
---|
1265 | 1254 | |
---|
.. | .. |
---|
1512 | 1501 | |
---|
1513 | 1502 | /** |
---|
1514 | 1503 | * atl1e_clean - NAPI Rx polling callback |
---|
| 1504 | + * @napi: napi info |
---|
| 1505 | + * @budget: number of packets to clean |
---|
1515 | 1506 | */ |
---|
1516 | 1507 | static int atl1e_clean(struct napi_struct *napi, int budget) |
---|
1517 | 1508 | { |
---|
.. | .. |
---|
1651 | 1642 | real_len = (((unsigned char *)ip_hdr(skb) - skb->data) |
---|
1652 | 1643 | + ntohs(ip_hdr(skb)->tot_len)); |
---|
1653 | 1644 | |
---|
1654 | | - if (real_len < skb->len) |
---|
1655 | | - pskb_trim(skb, real_len); |
---|
| 1645 | + if (real_len < skb->len) { |
---|
| 1646 | + err = pskb_trim(skb, real_len); |
---|
| 1647 | + if (err) |
---|
| 1648 | + return err; |
---|
| 1649 | + } |
---|
1656 | 1650 | |
---|
1657 | 1651 | hdr_len = (skb_transport_offset(skb) + tcp_hdrlen(skb)); |
---|
1658 | 1652 | if (unlikely(skb->len == hdr_len)) { |
---|
.. | .. |
---|
1727 | 1721 | |
---|
1728 | 1722 | tx_buffer = atl1e_get_tx_buffer(adapter, use_tpd); |
---|
1729 | 1723 | tx_buffer->length = map_len; |
---|
1730 | | - tx_buffer->dma = pci_map_single(adapter->pdev, |
---|
1731 | | - skb->data, hdr_len, PCI_DMA_TODEVICE); |
---|
| 1724 | + tx_buffer->dma = dma_map_single(&adapter->pdev->dev, |
---|
| 1725 | + skb->data, hdr_len, |
---|
| 1726 | + DMA_TO_DEVICE); |
---|
1732 | 1727 | if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) |
---|
1733 | 1728 | return -ENOSPC; |
---|
1734 | 1729 | |
---|
.. | .. |
---|
1756 | 1751 | ((buf_len - mapped_len) >= MAX_TX_BUF_LEN) ? |
---|
1757 | 1752 | MAX_TX_BUF_LEN : (buf_len - mapped_len); |
---|
1758 | 1753 | tx_buffer->dma = |
---|
1759 | | - pci_map_single(adapter->pdev, skb->data + mapped_len, |
---|
1760 | | - map_len, PCI_DMA_TODEVICE); |
---|
| 1754 | + dma_map_single(&adapter->pdev->dev, |
---|
| 1755 | + skb->data + mapped_len, map_len, |
---|
| 1756 | + DMA_TO_DEVICE); |
---|
1761 | 1757 | |
---|
1762 | 1758 | if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { |
---|
1763 | 1759 | /* We need to unwind the mappings we've done */ |
---|
.. | .. |
---|
1766 | 1762 | while (adapter->tx_ring.next_to_use != ring_end) { |
---|
1767 | 1763 | tpd = atl1e_get_tpd(adapter); |
---|
1768 | 1764 | tx_buffer = atl1e_get_tx_buffer(adapter, tpd); |
---|
1769 | | - pci_unmap_single(adapter->pdev, tx_buffer->dma, |
---|
1770 | | - tx_buffer->length, PCI_DMA_TODEVICE); |
---|
| 1765 | + dma_unmap_single(&adapter->pdev->dev, |
---|
| 1766 | + tx_buffer->dma, |
---|
| 1767 | + tx_buffer->length, |
---|
| 1768 | + DMA_TO_DEVICE); |
---|
1771 | 1769 | } |
---|
1772 | 1770 | /* Reset the tx rings next pointer */ |
---|
1773 | 1771 | adapter->tx_ring.next_to_use = ring_start; |
---|
.. | .. |
---|
1783 | 1781 | } |
---|
1784 | 1782 | |
---|
1785 | 1783 | for (f = 0; f < nr_frags; f++) { |
---|
1786 | | - const struct skb_frag_struct *frag; |
---|
| 1784 | + const skb_frag_t *frag = &skb_shinfo(skb)->frags[f]; |
---|
1787 | 1785 | u16 i; |
---|
1788 | 1786 | u16 seg_num; |
---|
1789 | 1787 | |
---|
1790 | | - frag = &skb_shinfo(skb)->frags[f]; |
---|
1791 | 1788 | buf_len = skb_frag_size(frag); |
---|
1792 | 1789 | |
---|
1793 | 1790 | seg_num = (buf_len + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN; |
---|
.. | .. |
---|
2318 | 2315 | * various kernel subsystems to support the mechanics required by a |
---|
2319 | 2316 | * fixed-high-32-bit system. |
---|
2320 | 2317 | */ |
---|
2321 | | - if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) || |
---|
2322 | | - (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)) { |
---|
| 2318 | + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
---|
| 2319 | + if (err) { |
---|
2323 | 2320 | dev_err(&pdev->dev, "No usable DMA configuration,aborting\n"); |
---|
2324 | 2321 | goto err_dma; |
---|
2325 | 2322 | } |
---|