hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
....@@ -1,24 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2003 - 2009 NetXen, Inc.
34 * Copyright (C) 2009 - QLogic Corporation.
45 * 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
- *
226 */
237
248 #include <linux/slab.h>
....@@ -65,7 +49,7 @@
6549 static int netxen_nic_close(struct net_device *netdev);
6650 static netdev_tx_t netxen_nic_xmit_frame(struct sk_buff *,
6751 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);
6953 static void netxen_tx_timeout_task(struct work_struct *work);
7054 static void netxen_fw_poll_work(struct work_struct *work);
7155 static void netxen_schedule_work(struct netxen_adapter *adapter,
....@@ -1708,19 +1692,13 @@
17081692 clear_bit(__NX_RESETTING, &adapter->state);
17091693 }
17101694
1711
-static int netxen_nic_attach_func(struct pci_dev *pdev)
1695
+static int netxen_nic_attach_late_func(struct pci_dev *pdev)
17121696 {
17131697 struct netxen_adapter *adapter = pci_get_drvdata(pdev);
17141698 struct net_device *netdev = adapter->netdev;
17151699 int err;
17161700
1717
- err = pci_enable_device(pdev);
1718
- if (err)
1719
- return err;
1720
-
1721
- pci_set_power_state(pdev, PCI_D0);
17221701 pci_set_master(pdev);
1723
- pci_restore_state(pdev);
17241702
17251703 adapter->ahw.crb_win = -1;
17261704 adapter->ahw.ocm_win = -1;
....@@ -1754,6 +1732,20 @@
17541732 return err;
17551733 }
17561734
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
+
17571749 static pci_ers_result_t netxen_io_error_detected(struct pci_dev *pdev,
17581750 pci_channel_state_t state)
17591751 {
....@@ -1781,11 +1773,6 @@
17811773 return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
17821774 }
17831775
1784
-static void netxen_io_resume(struct pci_dev *pdev)
1785
-{
1786
- pci_cleanup_aer_uncorrect_error_status(pdev);
1787
-}
1788
-
17891776 static void netxen_nic_shutdown(struct pci_dev *pdev)
17901777 {
17911778 struct netxen_adapter *adapter = pci_get_drvdata(pdev);
....@@ -1803,36 +1790,24 @@
18031790 pci_disable_device(pdev);
18041791 }
18051792
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)
18091795 {
1810
- struct netxen_adapter *adapter = pci_get_drvdata(pdev);
1811
- int retval;
1796
+ struct netxen_adapter *adapter = dev_get_drvdata(dev_d);
18121797
18131798 netxen_nic_detach_func(adapter);
18141799
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);
18261802
18271803 return 0;
18281804 }
18291805
1830
-static int
1831
-netxen_nic_resume(struct pci_dev *pdev)
1806
+static int __maybe_unused
1807
+netxen_nic_resume(struct device *dev_d)
18321808 {
1833
- return netxen_nic_attach_func(pdev);
1809
+ return netxen_nic_attach_late_func(to_pci_dev(dev_d));
18341810 }
1835
-#endif
18361811
18371812 static int netxen_nic_open(struct net_device *netdev)
18381813 {
....@@ -1998,7 +1973,7 @@
19981973 struct sk_buff *skb, struct netxen_cmd_buffer *pbuf)
19991974 {
20001975 struct netxen_skb_frag *nf;
2001
- struct skb_frag_struct *frag;
1976
+ skb_frag_t *frag;
20021977 int i, nr_frags;
20031978 dma_addr_t map;
20041979
....@@ -2061,7 +2036,7 @@
20612036 struct pci_dev *pdev;
20622037 int i, k;
20632038 int delta = 0;
2064
- struct skb_frag_struct *frag;
2039
+ skb_frag_t *frag;
20652040
20662041 u32 producer;
20672042 int frag_count;
....@@ -2240,7 +2215,7 @@
22402215 netxen_advert_link_change(adapter, linkup);
22412216 }
22422217
2243
-static void netxen_tx_timeout(struct net_device *netdev)
2218
+static void netxen_tx_timeout(struct net_device *netdev, unsigned int txqueue)
22442219 {
22452220 struct netxen_adapter *adapter = netdev_priv(netdev);
22462221
....@@ -3266,6 +3241,7 @@
32663241 struct net_device *dev, unsigned long event)
32673242 {
32683243 struct in_device *indev;
3244
+ struct in_ifaddr *ifa;
32693245
32703246 if (!netxen_destip_supported(adapter))
32713247 return;
....@@ -3274,7 +3250,8 @@
32743250 if (!indev)
32753251 return;
32763252
3277
- for_ifa(indev) {
3253
+ rcu_read_lock();
3254
+ in_dev_for_each_ifa_rcu(ifa, indev) {
32783255 switch (event) {
32793256 case NETDEV_UP:
32803257 netxen_list_config_ip(adapter, ifa, NX_IP_UP);
....@@ -3285,8 +3262,8 @@
32853262 default:
32863263 break;
32873264 }
3288
- } endfor_ifa(indev);
3289
-
3265
+ }
3266
+ rcu_read_unlock();
32903267 in_dev_put(indev);
32913268 }
32923269
....@@ -3462,18 +3439,18 @@
34623439 static const struct pci_error_handlers netxen_err_handler = {
34633440 .error_detected = netxen_io_error_detected,
34643441 .slot_reset = netxen_io_slot_reset,
3465
- .resume = netxen_io_resume,
34663442 };
3443
+
3444
+static SIMPLE_DEV_PM_OPS(netxen_nic_pm_ops,
3445
+ netxen_nic_suspend,
3446
+ netxen_nic_resume);
34673447
34683448 static struct pci_driver netxen_driver = {
34693449 .name = netxen_nic_driver_name,
34703450 .id_table = netxen_pci_tbl,
34713451 .probe = netxen_nic_probe,
34723452 .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,
34773454 .shutdown = netxen_nic_shutdown,
34783455 .err_handler = &netxen_err_handler
34793456 };