.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright(c) 2008 - 2009 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 "atl1c.h" |
---|
23 | 10 | |
---|
24 | | -#define ATL1C_DRV_VERSION "1.0.1.1-NAPI" |
---|
25 | 11 | char atl1c_driver_name[] = "atl1c"; |
---|
26 | | -char atl1c_driver_version[] = ATL1C_DRV_VERSION; |
---|
27 | 12 | |
---|
28 | 13 | /* |
---|
29 | 14 | * atl1c_pci_tbl - PCI Device ID Table |
---|
.. | .. |
---|
50 | 35 | MODULE_AUTHOR("Qualcomm Atheros Inc., <nic-devel@qualcomm.com>"); |
---|
51 | 36 | MODULE_DESCRIPTION("Qualcomm Atheros 100/1000M Ethernet Network Driver"); |
---|
52 | 37 | MODULE_LICENSE("GPL"); |
---|
53 | | -MODULE_VERSION(ATL1C_DRV_VERSION); |
---|
54 | 38 | |
---|
55 | 39 | static int atl1c_stop_mac(struct atl1c_hw *hw); |
---|
56 | 40 | static void atl1c_disable_l0s_l1(struct atl1c_hw *hw); |
---|
.. | .. |
---|
220 | 204 | |
---|
221 | 205 | /** |
---|
222 | 206 | * atl1c_phy_config - Timer Call-back |
---|
223 | | - * @data: pointer to netdev cast into an unsigned long |
---|
| 207 | + * @t: timer list containing pointer to netdev cast into an unsigned long |
---|
224 | 208 | */ |
---|
225 | 209 | static void atl1c_phy_config(struct timer_list *t) |
---|
226 | 210 | { |
---|
.. | .. |
---|
236 | 220 | |
---|
237 | 221 | void atl1c_reinit_locked(struct atl1c_adapter *adapter) |
---|
238 | 222 | { |
---|
239 | | - WARN_ON(in_interrupt()); |
---|
240 | 223 | atl1c_down(adapter); |
---|
241 | 224 | atl1c_up(adapter); |
---|
242 | 225 | clear_bit(__AT_RESETTING, &adapter->flags); |
---|
.. | .. |
---|
362 | 345 | /** |
---|
363 | 346 | * atl1c_tx_timeout - Respond to a Tx Hang |
---|
364 | 347 | * @netdev: network interface device structure |
---|
| 348 | + * @txqueue: index of hanging tx queue |
---|
365 | 349 | */ |
---|
366 | | -static void atl1c_tx_timeout(struct net_device *netdev) |
---|
| 350 | +static void atl1c_tx_timeout(struct net_device *netdev, unsigned int txqueue) |
---|
367 | 351 | { |
---|
368 | 352 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
---|
369 | 353 | |
---|
.. | .. |
---|
842 | 826 | return; |
---|
843 | 827 | if (buffer_info->dma) { |
---|
844 | 828 | if (buffer_info->flags & ATL1C_PCIMAP_FROMDEVICE) |
---|
845 | | - pci_driection = PCI_DMA_FROMDEVICE; |
---|
| 829 | + pci_driection = DMA_FROM_DEVICE; |
---|
846 | 830 | else |
---|
847 | | - pci_driection = PCI_DMA_TODEVICE; |
---|
| 831 | + pci_driection = DMA_TO_DEVICE; |
---|
848 | 832 | |
---|
849 | 833 | if (buffer_info->flags & ATL1C_PCIMAP_SINGLE) |
---|
850 | | - pci_unmap_single(pdev, buffer_info->dma, |
---|
851 | | - buffer_info->length, pci_driection); |
---|
| 834 | + dma_unmap_single(&pdev->dev, buffer_info->dma, |
---|
| 835 | + buffer_info->length, pci_driection); |
---|
852 | 836 | else if (buffer_info->flags & ATL1C_PCIMAP_PAGE) |
---|
853 | | - pci_unmap_page(pdev, buffer_info->dma, |
---|
854 | | - buffer_info->length, pci_driection); |
---|
| 837 | + dma_unmap_page(&pdev->dev, buffer_info->dma, |
---|
| 838 | + buffer_info->length, pci_driection); |
---|
855 | 839 | } |
---|
856 | 840 | if (buffer_info->skb) |
---|
857 | 841 | dev_consume_skb_any(buffer_info->skb); |
---|
.. | .. |
---|
862 | 846 | /** |
---|
863 | 847 | * atl1c_clean_tx_ring - Free Tx-skb |
---|
864 | 848 | * @adapter: board private structure |
---|
| 849 | + * @type: type of transmit queue |
---|
865 | 850 | */ |
---|
866 | 851 | static void atl1c_clean_tx_ring(struct atl1c_adapter *adapter, |
---|
867 | 852 | enum atl1c_trans_queue type) |
---|
.. | .. |
---|
949 | 934 | { |
---|
950 | 935 | struct pci_dev *pdev = adapter->pdev; |
---|
951 | 936 | |
---|
952 | | - pci_free_consistent(pdev, adapter->ring_header.size, |
---|
953 | | - adapter->ring_header.desc, |
---|
954 | | - adapter->ring_header.dma); |
---|
| 937 | + dma_free_coherent(&pdev->dev, adapter->ring_header.size, |
---|
| 938 | + adapter->ring_header.desc, adapter->ring_header.dma); |
---|
955 | 939 | adapter->ring_header.desc = NULL; |
---|
956 | 940 | |
---|
957 | 941 | /* Note: just free tdp_ring.buffer_info, |
---|
.. | .. |
---|
1019 | 1003 | sizeof(struct atl1c_recv_ret_status) * rx_desc_count + |
---|
1020 | 1004 | 8 * 4; |
---|
1021 | 1005 | |
---|
1022 | | - ring_header->desc = dma_zalloc_coherent(&pdev->dev, ring_header->size, |
---|
1023 | | - &ring_header->dma, GFP_KERNEL); |
---|
| 1006 | + ring_header->desc = dma_alloc_coherent(&pdev->dev, ring_header->size, |
---|
| 1007 | + &ring_header->dma, GFP_KERNEL); |
---|
1024 | 1008 | if (unlikely(!ring_header->desc)) { |
---|
1025 | 1009 | dev_err(&pdev->dev, "could not get memory for DMA buffer\n"); |
---|
1026 | 1010 | goto err_nomem; |
---|
.. | .. |
---|
1202 | 1186 | struct atl1c_hw *hw = &adapter->hw; |
---|
1203 | 1187 | u32 mac, txq, rxq; |
---|
1204 | 1188 | |
---|
1205 | | - hw->mac_duplex = adapter->link_duplex == FULL_DUPLEX ? true : false; |
---|
| 1189 | + hw->mac_duplex = adapter->link_duplex == FULL_DUPLEX; |
---|
1206 | 1190 | hw->mac_speed = adapter->link_speed == SPEED_1000 ? |
---|
1207 | 1191 | atl1c_mac_speed_1000 : atl1c_mac_speed_10_100; |
---|
1208 | 1192 | |
---|
.. | .. |
---|
1733 | 1717 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); |
---|
1734 | 1718 | buffer_info->skb = skb; |
---|
1735 | 1719 | buffer_info->length = adapter->rx_buffer_len; |
---|
1736 | | - mapping = pci_map_single(pdev, vir_addr, |
---|
1737 | | - buffer_info->length, |
---|
1738 | | - PCI_DMA_FROMDEVICE); |
---|
1739 | | - if (unlikely(pci_dma_mapping_error(pdev, mapping))) { |
---|
| 1720 | + mapping = dma_map_single(&pdev->dev, vir_addr, |
---|
| 1721 | + buffer_info->length, DMA_FROM_DEVICE); |
---|
| 1722 | + if (unlikely(dma_mapping_error(&pdev->dev, mapping))) { |
---|
1740 | 1723 | dev_kfree_skb(skb); |
---|
1741 | 1724 | buffer_info->skb = NULL; |
---|
1742 | 1725 | buffer_info->length = 0; |
---|
.. | .. |
---|
1833 | 1816 | atl1c_clean_rrd(rrd_ring, rrs, rfd_num); |
---|
1834 | 1817 | if (rrs->word3 & (RRS_RX_ERR_SUM | RRS_802_3_LEN_ERR)) { |
---|
1835 | 1818 | atl1c_clean_rfd(rfd_ring, rrs, rfd_num); |
---|
1836 | | - if (netif_msg_rx_err(adapter)) |
---|
1837 | | - dev_warn(&pdev->dev, |
---|
1838 | | - "wrong packet! rrs word3 is %x\n", |
---|
1839 | | - rrs->word3); |
---|
| 1819 | + if (netif_msg_rx_err(adapter)) |
---|
| 1820 | + dev_warn(&pdev->dev, |
---|
| 1821 | + "wrong packet! rrs word3 is %x\n", |
---|
| 1822 | + rrs->word3); |
---|
1840 | 1823 | continue; |
---|
1841 | 1824 | } |
---|
1842 | 1825 | |
---|
.. | .. |
---|
1847 | 1830 | rfd_index = (rrs->word0 >> RRS_RX_RFD_INDEX_SHIFT) & |
---|
1848 | 1831 | RRS_RX_RFD_INDEX_MASK; |
---|
1849 | 1832 | buffer_info = &rfd_ring->buffer_info[rfd_index]; |
---|
1850 | | - pci_unmap_single(pdev, buffer_info->dma, |
---|
1851 | | - buffer_info->length, PCI_DMA_FROMDEVICE); |
---|
| 1833 | + dma_unmap_single(&pdev->dev, buffer_info->dma, |
---|
| 1834 | + buffer_info->length, DMA_FROM_DEVICE); |
---|
1852 | 1835 | skb = buffer_info->skb; |
---|
1853 | 1836 | } else { |
---|
1854 | 1837 | /* TODO */ |
---|
.. | .. |
---|
1879 | 1862 | |
---|
1880 | 1863 | /** |
---|
1881 | 1864 | * atl1c_clean - NAPI Rx polling callback |
---|
| 1865 | + * @napi: napi info |
---|
| 1866 | + * @budget: limit of packets to clean |
---|
1882 | 1867 | */ |
---|
1883 | 1868 | static int atl1c_clean(struct napi_struct *napi, int budget) |
---|
1884 | 1869 | { |
---|
.. | .. |
---|
2002 | 1987 | real_len = (((unsigned char *)ip_hdr(skb) - skb->data) |
---|
2003 | 1988 | + ntohs(ip_hdr(skb)->tot_len)); |
---|
2004 | 1989 | |
---|
2005 | | - if (real_len < skb->len) |
---|
2006 | | - pskb_trim(skb, real_len); |
---|
| 1990 | + if (real_len < skb->len) { |
---|
| 1991 | + err = pskb_trim(skb, real_len); |
---|
| 1992 | + if (err) |
---|
| 1993 | + return err; |
---|
| 1994 | + } |
---|
2007 | 1995 | |
---|
2008 | 1996 | hdr_len = (skb_transport_offset(skb) + tcp_hdrlen(skb)); |
---|
2009 | 1997 | if (unlikely(skb->len == hdr_len)) { |
---|
.. | .. |
---|
2038 | 2026 | "IPV6 tso with zero data??\n"); |
---|
2039 | 2027 | goto check_sum; |
---|
2040 | 2028 | } else |
---|
2041 | | - tcp_hdr(skb)->check = ~csum_ipv6_magic( |
---|
2042 | | - &ipv6_hdr(skb)->saddr, |
---|
2043 | | - &ipv6_hdr(skb)->daddr, |
---|
2044 | | - 0, IPPROTO_TCP, 0); |
---|
| 2029 | + tcp_v6_gso_csum_prep(skb); |
---|
| 2030 | + |
---|
2045 | 2031 | etpd->word1 |= 1 << TPD_LSO_EN_SHIFT; |
---|
2046 | 2032 | etpd->word1 |= 1 << TPD_LSO_VER_SHIFT; |
---|
2047 | 2033 | etpd->pkt_len = cpu_to_le32(skb->len); |
---|
.. | .. |
---|
2124 | 2110 | |
---|
2125 | 2111 | buffer_info = atl1c_get_tx_buffer(adapter, use_tpd); |
---|
2126 | 2112 | buffer_info->length = map_len; |
---|
2127 | | - buffer_info->dma = pci_map_single(adapter->pdev, |
---|
2128 | | - skb->data, hdr_len, PCI_DMA_TODEVICE); |
---|
2129 | | - if (unlikely(pci_dma_mapping_error(adapter->pdev, |
---|
2130 | | - buffer_info->dma))) |
---|
| 2113 | + buffer_info->dma = dma_map_single(&adapter->pdev->dev, |
---|
| 2114 | + skb->data, hdr_len, |
---|
| 2115 | + DMA_TO_DEVICE); |
---|
| 2116 | + if (unlikely(dma_mapping_error(&adapter->pdev->dev, buffer_info->dma))) |
---|
2131 | 2117 | goto err_dma; |
---|
2132 | 2118 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); |
---|
2133 | 2119 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE, |
---|
.. | .. |
---|
2149 | 2135 | buffer_info = atl1c_get_tx_buffer(adapter, use_tpd); |
---|
2150 | 2136 | buffer_info->length = buf_len - mapped_len; |
---|
2151 | 2137 | buffer_info->dma = |
---|
2152 | | - pci_map_single(adapter->pdev, skb->data + mapped_len, |
---|
2153 | | - buffer_info->length, PCI_DMA_TODEVICE); |
---|
2154 | | - if (unlikely(pci_dma_mapping_error(adapter->pdev, |
---|
2155 | | - buffer_info->dma))) |
---|
| 2138 | + dma_map_single(&adapter->pdev->dev, |
---|
| 2139 | + skb->data + mapped_len, |
---|
| 2140 | + buffer_info->length, DMA_TO_DEVICE); |
---|
| 2141 | + if (unlikely(dma_mapping_error(&adapter->pdev->dev, buffer_info->dma))) |
---|
2156 | 2142 | goto err_dma; |
---|
2157 | 2143 | |
---|
2158 | 2144 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); |
---|
.. | .. |
---|
2163 | 2149 | } |
---|
2164 | 2150 | |
---|
2165 | 2151 | for (f = 0; f < nr_frags; f++) { |
---|
2166 | | - struct skb_frag_struct *frag; |
---|
2167 | | - |
---|
2168 | | - frag = &skb_shinfo(skb)->frags[f]; |
---|
| 2152 | + skb_frag_t *frag = &skb_shinfo(skb)->frags[f]; |
---|
2169 | 2153 | |
---|
2170 | 2154 | use_tpd = atl1c_get_tpd(adapter, type); |
---|
2171 | 2155 | memcpy(use_tpd, tpd, sizeof(struct atl1c_tpd_desc)); |
---|
.. | .. |
---|
2214 | 2198 | struct net_device *netdev) |
---|
2215 | 2199 | { |
---|
2216 | 2200 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
---|
2217 | | - u16 tpd_req = 1; |
---|
| 2201 | + u16 tpd_req; |
---|
2218 | 2202 | struct atl1c_tpd_desc *tpd; |
---|
2219 | 2203 | enum atl1c_trans_queue type = atl1c_trans_normal; |
---|
2220 | 2204 | |
---|
.. | .. |
---|
2435 | 2419 | |
---|
2436 | 2420 | static int atl1c_suspend(struct device *dev) |
---|
2437 | 2421 | { |
---|
2438 | | - struct pci_dev *pdev = to_pci_dev(dev); |
---|
2439 | | - struct net_device *netdev = pci_get_drvdata(pdev); |
---|
| 2422 | + struct net_device *netdev = dev_get_drvdata(dev); |
---|
2440 | 2423 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
---|
2441 | 2424 | struct atl1c_hw *hw = &adapter->hw; |
---|
2442 | 2425 | u32 wufc = adapter->wol; |
---|
.. | .. |
---|
2450 | 2433 | |
---|
2451 | 2434 | if (wufc) |
---|
2452 | 2435 | if (atl1c_phy_to_ps_link(hw) != 0) |
---|
2453 | | - dev_dbg(&pdev->dev, "phy power saving failed"); |
---|
| 2436 | + dev_dbg(dev, "phy power saving failed"); |
---|
2454 | 2437 | |
---|
2455 | 2438 | atl1c_power_saving(hw, wufc); |
---|
2456 | 2439 | |
---|
.. | .. |
---|
2460 | 2443 | #ifdef CONFIG_PM_SLEEP |
---|
2461 | 2444 | static int atl1c_resume(struct device *dev) |
---|
2462 | 2445 | { |
---|
2463 | | - struct pci_dev *pdev = to_pci_dev(dev); |
---|
2464 | | - struct net_device *netdev = pci_get_drvdata(pdev); |
---|
| 2446 | + struct net_device *netdev = dev_get_drvdata(dev); |
---|
2465 | 2447 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
---|
2466 | 2448 | |
---|
2467 | 2449 | AT_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0); |
---|
.. | .. |
---|
2470 | 2452 | atl1c_phy_reset(&adapter->hw); |
---|
2471 | 2453 | atl1c_reset_mac(&adapter->hw); |
---|
2472 | 2454 | atl1c_phy_init(&adapter->hw); |
---|
2473 | | - |
---|
2474 | | -#if 0 |
---|
2475 | | - AT_READ_REG(&adapter->hw, REG_PM_CTRLSTAT, &pm_data); |
---|
2476 | | - pm_data &= ~PM_CTRLSTAT_PME_EN; |
---|
2477 | | - AT_WRITE_REG(&adapter->hw, REG_PM_CTRLSTAT, pm_data); |
---|
2478 | | -#endif |
---|
2479 | 2455 | |
---|
2480 | 2456 | netif_device_attach(netdev); |
---|
2481 | 2457 | if (netif_running(netdev)) |
---|
.. | .. |
---|
2570 | 2546 | * various kernel subsystems to support the mechanics required by a |
---|
2571 | 2547 | * fixed-high-32-bit system. |
---|
2572 | 2548 | */ |
---|
2573 | | - if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) || |
---|
2574 | | - (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)) { |
---|
| 2549 | + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
---|
| 2550 | + if (err) { |
---|
2575 | 2551 | dev_err(&pdev->dev, "No usable DMA configuration,aborting\n"); |
---|
2576 | 2552 | goto err_dma; |
---|
2577 | 2553 | } |
---|
.. | .. |
---|
2661 | 2637 | goto err_register; |
---|
2662 | 2638 | } |
---|
2663 | 2639 | |
---|
2664 | | - if (netif_msg_probe(adapter)) |
---|
2665 | | - dev_info(&pdev->dev, "version %s\n", ATL1C_DRV_VERSION); |
---|
2666 | 2640 | cards_found++; |
---|
2667 | 2641 | return 0; |
---|
2668 | 2642 | |
---|