.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2003 - 2009 NetXen, Inc. |
---|
3 | 4 | * Copyright (C) 2009 - QLogic Corporation. |
---|
4 | 5 | * All rights reserved. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License |
---|
8 | | - * as published by the Free Software Foundation; either version 2 |
---|
9 | | - * of the License, or (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, but |
---|
12 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
---|
18 | | - * |
---|
19 | | - * The full GNU General Public License is included in this distribution |
---|
20 | | - * in the file called "COPYING". |
---|
21 | | - * |
---|
22 | 6 | */ |
---|
23 | 7 | |
---|
24 | 8 | #include <linux/slab.h> |
---|
.. | .. |
---|
65 | 49 | static int netxen_nic_close(struct net_device *netdev); |
---|
66 | 50 | static netdev_tx_t netxen_nic_xmit_frame(struct sk_buff *, |
---|
67 | 51 | struct net_device *); |
---|
68 | | -static void netxen_tx_timeout(struct net_device *netdev); |
---|
| 52 | +static void netxen_tx_timeout(struct net_device *netdev, unsigned int txqueue); |
---|
69 | 53 | static void netxen_tx_timeout_task(struct work_struct *work); |
---|
70 | 54 | static void netxen_fw_poll_work(struct work_struct *work); |
---|
71 | 55 | static void netxen_schedule_work(struct netxen_adapter *adapter, |
---|
.. | .. |
---|
1708 | 1692 | clear_bit(__NX_RESETTING, &adapter->state); |
---|
1709 | 1693 | } |
---|
1710 | 1694 | |
---|
1711 | | -static int netxen_nic_attach_func(struct pci_dev *pdev) |
---|
| 1695 | +static int netxen_nic_attach_late_func(struct pci_dev *pdev) |
---|
1712 | 1696 | { |
---|
1713 | 1697 | struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
---|
1714 | 1698 | struct net_device *netdev = adapter->netdev; |
---|
1715 | 1699 | int err; |
---|
1716 | 1700 | |
---|
1717 | | - err = pci_enable_device(pdev); |
---|
1718 | | - if (err) |
---|
1719 | | - return err; |
---|
1720 | | - |
---|
1721 | | - pci_set_power_state(pdev, PCI_D0); |
---|
1722 | 1701 | pci_set_master(pdev); |
---|
1723 | | - pci_restore_state(pdev); |
---|
1724 | 1702 | |
---|
1725 | 1703 | adapter->ahw.crb_win = -1; |
---|
1726 | 1704 | adapter->ahw.ocm_win = -1; |
---|
.. | .. |
---|
1754 | 1732 | return err; |
---|
1755 | 1733 | } |
---|
1756 | 1734 | |
---|
| 1735 | +static int netxen_nic_attach_func(struct pci_dev *pdev) |
---|
| 1736 | +{ |
---|
| 1737 | + int err; |
---|
| 1738 | + |
---|
| 1739 | + err = pci_enable_device(pdev); |
---|
| 1740 | + if (err) |
---|
| 1741 | + return err; |
---|
| 1742 | + |
---|
| 1743 | + pci_set_power_state(pdev, PCI_D0); |
---|
| 1744 | + pci_restore_state(pdev); |
---|
| 1745 | + |
---|
| 1746 | + return netxen_nic_attach_late_func(pdev); |
---|
| 1747 | +} |
---|
| 1748 | + |
---|
1757 | 1749 | static pci_ers_result_t netxen_io_error_detected(struct pci_dev *pdev, |
---|
1758 | 1750 | pci_channel_state_t state) |
---|
1759 | 1751 | { |
---|
.. | .. |
---|
1781 | 1773 | return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; |
---|
1782 | 1774 | } |
---|
1783 | 1775 | |
---|
1784 | | -static void netxen_io_resume(struct pci_dev *pdev) |
---|
1785 | | -{ |
---|
1786 | | - pci_cleanup_aer_uncorrect_error_status(pdev); |
---|
1787 | | -} |
---|
1788 | | - |
---|
1789 | 1776 | static void netxen_nic_shutdown(struct pci_dev *pdev) |
---|
1790 | 1777 | { |
---|
1791 | 1778 | struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
---|
.. | .. |
---|
1803 | 1790 | pci_disable_device(pdev); |
---|
1804 | 1791 | } |
---|
1805 | 1792 | |
---|
1806 | | -#ifdef CONFIG_PM |
---|
1807 | | -static int |
---|
1808 | | -netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state) |
---|
| 1793 | +static int __maybe_unused |
---|
| 1794 | +netxen_nic_suspend(struct device *dev_d) |
---|
1809 | 1795 | { |
---|
1810 | | - struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
---|
1811 | | - int retval; |
---|
| 1796 | + struct netxen_adapter *adapter = dev_get_drvdata(dev_d); |
---|
1812 | 1797 | |
---|
1813 | 1798 | netxen_nic_detach_func(adapter); |
---|
1814 | 1799 | |
---|
1815 | | - retval = pci_save_state(pdev); |
---|
1816 | | - if (retval) |
---|
1817 | | - return retval; |
---|
1818 | | - |
---|
1819 | | - if (netxen_nic_wol_supported(adapter)) { |
---|
1820 | | - pci_enable_wake(pdev, PCI_D3cold, 1); |
---|
1821 | | - pci_enable_wake(pdev, PCI_D3hot, 1); |
---|
1822 | | - } |
---|
1823 | | - |
---|
1824 | | - pci_disable_device(pdev); |
---|
1825 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
---|
| 1800 | + if (netxen_nic_wol_supported(adapter)) |
---|
| 1801 | + device_wakeup_enable(dev_d); |
---|
1826 | 1802 | |
---|
1827 | 1803 | return 0; |
---|
1828 | 1804 | } |
---|
1829 | 1805 | |
---|
1830 | | -static int |
---|
1831 | | -netxen_nic_resume(struct pci_dev *pdev) |
---|
| 1806 | +static int __maybe_unused |
---|
| 1807 | +netxen_nic_resume(struct device *dev_d) |
---|
1832 | 1808 | { |
---|
1833 | | - return netxen_nic_attach_func(pdev); |
---|
| 1809 | + return netxen_nic_attach_late_func(to_pci_dev(dev_d)); |
---|
1834 | 1810 | } |
---|
1835 | | -#endif |
---|
1836 | 1811 | |
---|
1837 | 1812 | static int netxen_nic_open(struct net_device *netdev) |
---|
1838 | 1813 | { |
---|
.. | .. |
---|
1998 | 1973 | struct sk_buff *skb, struct netxen_cmd_buffer *pbuf) |
---|
1999 | 1974 | { |
---|
2000 | 1975 | struct netxen_skb_frag *nf; |
---|
2001 | | - struct skb_frag_struct *frag; |
---|
| 1976 | + skb_frag_t *frag; |
---|
2002 | 1977 | int i, nr_frags; |
---|
2003 | 1978 | dma_addr_t map; |
---|
2004 | 1979 | |
---|
.. | .. |
---|
2061 | 2036 | struct pci_dev *pdev; |
---|
2062 | 2037 | int i, k; |
---|
2063 | 2038 | int delta = 0; |
---|
2064 | | - struct skb_frag_struct *frag; |
---|
| 2039 | + skb_frag_t *frag; |
---|
2065 | 2040 | |
---|
2066 | 2041 | u32 producer; |
---|
2067 | 2042 | int frag_count; |
---|
.. | .. |
---|
2240 | 2215 | netxen_advert_link_change(adapter, linkup); |
---|
2241 | 2216 | } |
---|
2242 | 2217 | |
---|
2243 | | -static void netxen_tx_timeout(struct net_device *netdev) |
---|
| 2218 | +static void netxen_tx_timeout(struct net_device *netdev, unsigned int txqueue) |
---|
2244 | 2219 | { |
---|
2245 | 2220 | struct netxen_adapter *adapter = netdev_priv(netdev); |
---|
2246 | 2221 | |
---|
.. | .. |
---|
3266 | 3241 | struct net_device *dev, unsigned long event) |
---|
3267 | 3242 | { |
---|
3268 | 3243 | struct in_device *indev; |
---|
| 3244 | + struct in_ifaddr *ifa; |
---|
3269 | 3245 | |
---|
3270 | 3246 | if (!netxen_destip_supported(adapter)) |
---|
3271 | 3247 | return; |
---|
.. | .. |
---|
3274 | 3250 | if (!indev) |
---|
3275 | 3251 | return; |
---|
3276 | 3252 | |
---|
3277 | | - for_ifa(indev) { |
---|
| 3253 | + rcu_read_lock(); |
---|
| 3254 | + in_dev_for_each_ifa_rcu(ifa, indev) { |
---|
3278 | 3255 | switch (event) { |
---|
3279 | 3256 | case NETDEV_UP: |
---|
3280 | 3257 | netxen_list_config_ip(adapter, ifa, NX_IP_UP); |
---|
.. | .. |
---|
3285 | 3262 | default: |
---|
3286 | 3263 | break; |
---|
3287 | 3264 | } |
---|
3288 | | - } endfor_ifa(indev); |
---|
3289 | | - |
---|
| 3265 | + } |
---|
| 3266 | + rcu_read_unlock(); |
---|
3290 | 3267 | in_dev_put(indev); |
---|
3291 | 3268 | } |
---|
3292 | 3269 | |
---|
.. | .. |
---|
3462 | 3439 | static const struct pci_error_handlers netxen_err_handler = { |
---|
3463 | 3440 | .error_detected = netxen_io_error_detected, |
---|
3464 | 3441 | .slot_reset = netxen_io_slot_reset, |
---|
3465 | | - .resume = netxen_io_resume, |
---|
3466 | 3442 | }; |
---|
| 3443 | + |
---|
| 3444 | +static SIMPLE_DEV_PM_OPS(netxen_nic_pm_ops, |
---|
| 3445 | + netxen_nic_suspend, |
---|
| 3446 | + netxen_nic_resume); |
---|
3467 | 3447 | |
---|
3468 | 3448 | static struct pci_driver netxen_driver = { |
---|
3469 | 3449 | .name = netxen_nic_driver_name, |
---|
3470 | 3450 | .id_table = netxen_pci_tbl, |
---|
3471 | 3451 | .probe = netxen_nic_probe, |
---|
3472 | 3452 | .remove = netxen_nic_remove, |
---|
3473 | | -#ifdef CONFIG_PM |
---|
3474 | | - .suspend = netxen_nic_suspend, |
---|
3475 | | - .resume = netxen_nic_resume, |
---|
3476 | | -#endif |
---|
| 3453 | + .driver.pm = &netxen_nic_pm_ops, |
---|
3477 | 3454 | .shutdown = netxen_nic_shutdown, |
---|
3478 | 3455 | .err_handler = &netxen_err_handler |
---|
3479 | 3456 | }; |
---|