hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
....@@ -1,8 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * QLogic qlcnic NIC Driver
34 * Copyright (c) 2009-2013 QLogic Corporation
4
- *
5
- * See LICENSE.qlcnic for copyright and licensing details.
65 */
76
87 #include <linux/vmalloc.h>
....@@ -56,7 +55,7 @@
5655 static void qlcnic_remove(struct pci_dev *pdev);
5756 static int qlcnic_open(struct net_device *netdev);
5857 static int qlcnic_close(struct net_device *netdev);
59
-static void qlcnic_tx_timeout(struct net_device *netdev);
58
+static void qlcnic_tx_timeout(struct net_device *netdev, unsigned int txqueue);
6059 static void qlcnic_attach_work(struct work_struct *work);
6160 static void qlcnic_fwinit_work(struct work_struct *work);
6261
....@@ -396,7 +395,8 @@
396395
397396 static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
398397 struct net_device *netdev,
399
- const unsigned char *addr, u16 vid, u16 flags)
398
+ const unsigned char *addr, u16 vid, u16 flags,
399
+ struct netlink_ext_ack *extack)
400400 {
401401 struct qlcnic_adapter *adapter = netdev_priv(netdev);
402402 int err = 0;
....@@ -470,48 +470,29 @@
470470 return 0;
471471 }
472472
473
-static void qlcnic_add_vxlan_port(struct net_device *netdev,
474
- struct udp_tunnel_info *ti)
473
+static int qlcnic_udp_tunnel_sync(struct net_device *dev, unsigned int table)
475474 {
476
- struct qlcnic_adapter *adapter = netdev_priv(netdev);
477
- struct qlcnic_hardware_context *ahw = adapter->ahw;
475
+ struct qlcnic_adapter *adapter = netdev_priv(dev);
476
+ struct udp_tunnel_info ti;
477
+ int err;
478478
479
- if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
480
- return;
481
-
482
- /* Adapter supports only one VXLAN port. Use very first port
483
- * for enabling offload
484
- */
485
- if (!qlcnic_encap_rx_offload(adapter))
486
- return;
487
- if (!ahw->vxlan_port_count) {
488
- ahw->vxlan_port_count = 1;
489
- ahw->vxlan_port = ntohs(ti->port);
490
- adapter->flags |= QLCNIC_ADD_VXLAN_PORT;
491
- return;
479
+ udp_tunnel_nic_get_port(dev, table, 0, &ti);
480
+ if (ti.port) {
481
+ err = qlcnic_set_vxlan_port(adapter, ntohs(ti.port));
482
+ if (err)
483
+ return err;
492484 }
493
- if (ahw->vxlan_port == ntohs(ti->port))
494
- ahw->vxlan_port_count++;
495485
486
+ return qlcnic_set_vxlan_parsing(adapter, ntohs(ti.port));
496487 }
497488
498
-static void qlcnic_del_vxlan_port(struct net_device *netdev,
499
- struct udp_tunnel_info *ti)
500
-{
501
- struct qlcnic_adapter *adapter = netdev_priv(netdev);
502
- struct qlcnic_hardware_context *ahw = adapter->ahw;
503
-
504
- if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
505
- return;
506
-
507
- if (!qlcnic_encap_rx_offload(adapter) || !ahw->vxlan_port_count ||
508
- (ahw->vxlan_port != ntohs(ti->port)))
509
- return;
510
-
511
- ahw->vxlan_port_count--;
512
- if (!ahw->vxlan_port_count)
513
- adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
514
-}
489
+static const struct udp_tunnel_nic_info qlcnic_udp_tunnels = {
490
+ .sync_table = qlcnic_udp_tunnel_sync,
491
+ .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP,
492
+ .tables = {
493
+ { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
494
+ },
495
+};
515496
516497 static netdev_features_t qlcnic_features_check(struct sk_buff *skb,
517498 struct net_device *dev,
....@@ -539,8 +520,8 @@
539520 .ndo_fdb_del = qlcnic_fdb_del,
540521 .ndo_fdb_dump = qlcnic_fdb_dump,
541522 .ndo_get_phys_port_id = qlcnic_get_phys_port_id,
542
- .ndo_udp_tunnel_add = qlcnic_add_vxlan_port,
543
- .ndo_udp_tunnel_del = qlcnic_del_vxlan_port,
523
+ .ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
524
+ .ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
544525 .ndo_features_check = qlcnic_features_check,
545526 #ifdef CONFIG_QLCNIC_SRIOV
546527 .ndo_set_vf_mac = qlcnic_sriov_set_vf_mac,
....@@ -2016,7 +1997,7 @@
20161997 qlcnic_create_sysfs_entries(adapter);
20171998
20181999 if (qlcnic_encap_rx_offload(adapter))
2019
- udp_tunnel_get_rx_info(netdev);
2000
+ udp_tunnel_nic_reset_ntf(netdev);
20202001
20212002 adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC;
20222003 return 0;
....@@ -2334,8 +2315,11 @@
23342315 NETIF_F_TSO6;
23352316 }
23362317
2337
- if (qlcnic_encap_rx_offload(adapter))
2318
+ if (qlcnic_encap_rx_offload(adapter)) {
23382319 netdev->hw_enc_features |= NETIF_F_RXCSUM;
2320
+
2321
+ netdev->udp_tunnel_nic_info = &qlcnic_udp_tunnels;
2322
+ }
23392323
23402324 netdev->hw_features = netdev->features;
23412325 netdev->priv_flags |= IFF_UNICAST_FLT;
....@@ -2638,7 +2622,13 @@
26382622 "Device does not support MSI interrupts\n");
26392623
26402624 if (qlcnic_82xx_check(adapter)) {
2641
- qlcnic_dcb_enable(adapter->dcb);
2625
+ err = qlcnic_dcb_enable(adapter->dcb);
2626
+ if (err) {
2627
+ qlcnic_dcb_free(adapter->dcb);
2628
+ dev_err(&pdev->dev, "Failed to enable DCB\n");
2629
+ goto err_out_free_hw;
2630
+ }
2631
+
26422632 qlcnic_dcb_get_info(adapter->dcb);
26432633 err = qlcnic_setup_intr(adapter);
26442634
....@@ -2812,35 +2802,17 @@
28122802 pci_disable_device(pdev);
28132803 }
28142804
2815
-#ifdef CONFIG_PM
2816
-static int qlcnic_suspend(struct pci_dev *pdev, pm_message_t state)
2805
+static int __maybe_unused qlcnic_suspend(struct device *dev_d)
28172806 {
2818
- int retval;
2819
-
2820
- retval = __qlcnic_shutdown(pdev);
2821
- if (retval)
2822
- return retval;
2823
-
2824
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
2825
- return 0;
2807
+ return __qlcnic_shutdown(to_pci_dev(dev_d));
28262808 }
28272809
2828
-static int qlcnic_resume(struct pci_dev *pdev)
2810
+static int __maybe_unused qlcnic_resume(struct device *dev_d)
28292811 {
2830
- struct qlcnic_adapter *adapter = pci_get_drvdata(pdev);
2831
- int err;
2832
-
2833
- err = pci_enable_device(pdev);
2834
- if (err)
2835
- return err;
2836
-
2837
- pci_set_power_state(pdev, PCI_D0);
2838
- pci_set_master(pdev);
2839
- pci_restore_state(pdev);
2812
+ struct qlcnic_adapter *adapter = dev_get_drvdata(dev_d);
28402813
28412814 return __qlcnic_resume(adapter);
28422815 }
2843
-#endif
28442816
28452817 static int qlcnic_open(struct net_device *netdev)
28462818 {
....@@ -2995,10 +2967,8 @@
29952967 static inline void dump_tx_ring_desc(struct qlcnic_host_tx_ring *tx_ring)
29962968 {
29972969 int i;
2998
- struct cmd_desc_type0 *tx_desc_info;
29992970
30002971 for (i = 0; i < tx_ring->num_desc; i++) {
3001
- tx_desc_info = &tx_ring->desc_head[i];
30022972 pr_info("TX Desc: %d\n", i);
30032973 print_hex_dump(KERN_INFO, "TX: ", DUMP_PREFIX_OFFSET, 16, 1,
30042974 &tx_ring->desc_head[i],
....@@ -3071,7 +3041,7 @@
30713041
30723042 }
30733043
3074
-static void qlcnic_tx_timeout(struct net_device *netdev)
3044
+static void qlcnic_tx_timeout(struct net_device *netdev, unsigned int txqueue)
30753045 {
30763046 struct qlcnic_adapter *adapter = netdev_priv(netdev);
30773047
....@@ -3932,7 +3902,6 @@
39323902 u32 state;
39333903 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev);
39343904
3935
- pci_cleanup_aer_uncorrect_error_status(pdev);
39363905 state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
39373906 if (state == QLCNIC_DEV_READY && test_and_clear_bit(__QLCNIC_AER,
39383907 &adapter->state))
....@@ -4011,19 +3980,12 @@
40113980 int queue_type)
40123981 {
40133982 struct net_device *netdev = adapter->netdev;
4014
- u8 max_hw_rings = 0;
40153983 char buf[8];
4016
- int cur_rings;
40173984
4018
- if (queue_type == QLCNIC_RX_QUEUE) {
4019
- max_hw_rings = adapter->max_sds_rings;
4020
- cur_rings = adapter->drv_sds_rings;
3985
+ if (queue_type == QLCNIC_RX_QUEUE)
40213986 strcpy(buf, "SDS");
4022
- } else if (queue_type == QLCNIC_TX_QUEUE) {
4023
- max_hw_rings = adapter->max_tx_rings;
4024
- cur_rings = adapter->drv_tx_rings;
3987
+ else
40253988 strcpy(buf, "Tx");
4026
- }
40273989
40283990 if (!is_power_of_2(ring_cnt)) {
40293991 netdev_err(netdev, "%s rings value should be a power of 2\n",
....@@ -4130,13 +4092,14 @@
41304092 qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
41314093 struct net_device *dev, unsigned long event)
41324094 {
4095
+ const struct in_ifaddr *ifa;
41334096 struct in_device *indev;
41344097
41354098 indev = in_dev_get(dev);
41364099 if (!indev)
41374100 return;
41384101
4139
- for_ifa(indev) {
4102
+ in_dev_for_each_ifa_rtnl(ifa, indev) {
41404103 switch (event) {
41414104 case NETDEV_UP:
41424105 qlcnic_config_ipaddr(adapter,
....@@ -4149,7 +4112,7 @@
41494112 default:
41504113 break;
41514114 }
4152
- } endfor_ifa(indev);
4115
+ }
41534116
41544117 in_dev_put(indev);
41554118 }
....@@ -4268,15 +4231,14 @@
42684231 .resume = qlcnic_io_resume,
42694232 };
42704233
4234
+static SIMPLE_DEV_PM_OPS(qlcnic_pm_ops, qlcnic_suspend, qlcnic_resume);
4235
+
42714236 static struct pci_driver qlcnic_driver = {
42724237 .name = qlcnic_driver_name,
42734238 .id_table = qlcnic_pci_tbl,
42744239 .probe = qlcnic_probe,
42754240 .remove = qlcnic_remove,
4276
-#ifdef CONFIG_PM
4277
- .suspend = qlcnic_suspend,
4278
- .resume = qlcnic_resume,
4279
-#endif
4241
+ .driver.pm = &qlcnic_pm_ops,
42804242 .shutdown = qlcnic_shutdown,
42814243 .err_handler = &qlcnic_err_handler,
42824244 #ifdef CONFIG_QLCNIC_SRIOV