aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/dsa/b53/b53_common.c90
-rw-r--r--drivers/net/dsa/b53/b53_priv.h3
-rw-r--r--drivers/net/dsa/bcm_sf2.c12
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c28
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.c10
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.h2
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c4
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c4
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c5
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c7
-rw-r--r--drivers/net/ethernet/marvell/sky2.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h17
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/events.c17
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c12
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_iwarp.c21
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_iwarp.h1
-rw-r--r--drivers/net/ethernet/realtek/r8169.c21
-rw-r--r--drivers/net/ethernet/sfc/ef10.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c9
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c22
-rw-r--r--drivers/net/ethernet/ti/netcp_core.c2
-rw-r--r--drivers/net/phy/phy.c16
-rw-r--r--drivers/net/phy/phylink.c19
-rw-r--r--drivers/net/phy/sfp-bus.c2
-rw-r--r--drivers/net/phy/sfp.c30
-rw-r--r--drivers/net/phy/sfp.h2
-rw-r--r--drivers/net/phy/xilinx_gmii2rgmii.c5
-rw-r--r--drivers/net/team/team.c27
-rw-r--r--drivers/net/usb/qmi_wwan.c4
-rw-r--r--drivers/net/usb/r8152.c5
-rw-r--r--drivers/net/vxlan.c14
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/usb.c46
42 files changed, 362 insertions, 164 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index edb1c023a753..21bf8ac78380 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -197,9 +197,9 @@ config VXLAN
197 197
198config GENEVE 198config GENEVE
199 tristate "Generic Network Virtualization Encapsulation" 199 tristate "Generic Network Virtualization Encapsulation"
200 depends on INET && NET_UDP_TUNNEL 200 depends on INET
201 depends on IPV6 || !IPV6 201 depends on IPV6 || !IPV6
202 select NET_IP_TUNNEL 202 select NET_UDP_TUNNEL
203 select GRO_CELLS 203 select GRO_CELLS
204 ---help--- 204 ---help---
205 This allows one to create geneve virtual interfaces that provide 205 This allows one to create geneve virtual interfaces that provide
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 0e4bbdcc614f..c76892ac4e69 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -344,7 +344,8 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
344 b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt); 344 b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
345} 345}
346 346
347static void b53_enable_vlan(struct b53_device *dev, bool enable) 347static void b53_enable_vlan(struct b53_device *dev, bool enable,
348 bool enable_filtering)
348{ 349{
349 u8 mgmt, vc0, vc1, vc4 = 0, vc5; 350 u8 mgmt, vc0, vc1, vc4 = 0, vc5;
350 351
@@ -369,8 +370,13 @@ static void b53_enable_vlan(struct b53_device *dev, bool enable)
369 vc0 |= VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID; 370 vc0 |= VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID;
370 vc1 |= VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN; 371 vc1 |= VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN;
371 vc4 &= ~VC4_ING_VID_CHECK_MASK; 372 vc4 &= ~VC4_ING_VID_CHECK_MASK;
372 vc4 |= VC4_ING_VID_VIO_DROP << VC4_ING_VID_CHECK_S; 373 if (enable_filtering) {
373 vc5 |= VC5_DROP_VTABLE_MISS; 374 vc4 |= VC4_ING_VID_VIO_DROP << VC4_ING_VID_CHECK_S;
375 vc5 |= VC5_DROP_VTABLE_MISS;
376 } else {
377 vc4 |= VC4_ING_VID_VIO_FWD << VC4_ING_VID_CHECK_S;
378 vc5 &= ~VC5_DROP_VTABLE_MISS;
379 }
374 380
375 if (is5325(dev)) 381 if (is5325(dev))
376 vc0 &= ~VC0_RESERVED_1; 382 vc0 &= ~VC0_RESERVED_1;
@@ -420,6 +426,9 @@ static void b53_enable_vlan(struct b53_device *dev, bool enable)
420 } 426 }
421 427
422 b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt); 428 b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt);
429
430 dev->vlan_enabled = enable;
431 dev->vlan_filtering_enabled = enable_filtering;
423} 432}
424 433
425static int b53_set_jumbo(struct b53_device *dev, bool enable, bool allow_10_100) 434static int b53_set_jumbo(struct b53_device *dev, bool enable, bool allow_10_100)
@@ -632,25 +641,35 @@ static void b53_enable_mib(struct b53_device *dev)
632 b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc); 641 b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc);
633} 642}
634 643
644static u16 b53_default_pvid(struct b53_device *dev)
645{
646 if (is5325(dev) || is5365(dev))
647 return 1;
648 else
649 return 0;
650}
651
635int b53_configure_vlan(struct dsa_switch *ds) 652int b53_configure_vlan(struct dsa_switch *ds)
636{ 653{
637 struct b53_device *dev = ds->priv; 654 struct b53_device *dev = ds->priv;
638 struct b53_vlan vl = { 0 }; 655 struct b53_vlan vl = { 0 };
639 int i; 656 int i, def_vid;
657
658 def_vid = b53_default_pvid(dev);
640 659
641 /* clear all vlan entries */ 660 /* clear all vlan entries */
642 if (is5325(dev) || is5365(dev)) { 661 if (is5325(dev) || is5365(dev)) {
643 for (i = 1; i < dev->num_vlans; i++) 662 for (i = def_vid; i < dev->num_vlans; i++)
644 b53_set_vlan_entry(dev, i, &vl); 663 b53_set_vlan_entry(dev, i, &vl);
645 } else { 664 } else {
646 b53_do_vlan_op(dev, VTA_CMD_CLEAR); 665 b53_do_vlan_op(dev, VTA_CMD_CLEAR);
647 } 666 }
648 667
649 b53_enable_vlan(dev, false); 668 b53_enable_vlan(dev, false, dev->vlan_filtering_enabled);
650 669
651 b53_for_each_port(dev, i) 670 b53_for_each_port(dev, i)
652 b53_write16(dev, B53_VLAN_PAGE, 671 b53_write16(dev, B53_VLAN_PAGE,
653 B53_VLAN_PORT_DEF_TAG(i), 1); 672 B53_VLAN_PORT_DEF_TAG(i), def_vid);
654 673
655 if (!is5325(dev) && !is5365(dev)) 674 if (!is5325(dev) && !is5365(dev))
656 b53_set_jumbo(dev, dev->enable_jumbo, false); 675 b53_set_jumbo(dev, dev->enable_jumbo, false);
@@ -1255,6 +1274,46 @@ EXPORT_SYMBOL(b53_phylink_mac_link_up);
1255 1274
1256int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering) 1275int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering)
1257{ 1276{
1277 struct b53_device *dev = ds->priv;
1278 struct net_device *bridge_dev;
1279 unsigned int i;
1280 u16 pvid, new_pvid;
1281
1282 /* Handle the case were multiple bridges span the same switch device
1283 * and one of them has a different setting than what is being requested
1284 * which would be breaking filtering semantics for any of the other
1285 * bridge devices.
1286 */
1287 b53_for_each_port(dev, i) {
1288 bridge_dev = dsa_to_port(ds, i)->bridge_dev;
1289 if (bridge_dev &&
1290 bridge_dev != dsa_to_port(ds, port)->bridge_dev &&
1291 br_vlan_enabled(bridge_dev) != vlan_filtering) {
1292 netdev_err(bridge_dev,
1293 "VLAN filtering is global to the switch!\n");
1294 return -EINVAL;
1295 }
1296 }
1297
1298 b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
1299 new_pvid = pvid;
1300 if (dev->vlan_filtering_enabled && !vlan_filtering) {
1301 /* Filtering is currently enabled, use the default PVID since
1302 * the bridge does not expect tagging anymore
1303 */
1304 dev->ports[port].pvid = pvid;
1305 new_pvid = b53_default_pvid(dev);
1306 } else if (!dev->vlan_filtering_enabled && vlan_filtering) {
1307 /* Filtering is currently disabled, restore the previous PVID */
1308 new_pvid = dev->ports[port].pvid;
1309 }
1310
1311 if (pvid != new_pvid)
1312 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
1313 new_pvid);
1314
1315 b53_enable_vlan(dev, dev->vlan_enabled, vlan_filtering);
1316
1258 return 0; 1317 return 0;
1259} 1318}
1260EXPORT_SYMBOL(b53_vlan_filtering); 1319EXPORT_SYMBOL(b53_vlan_filtering);
@@ -1270,7 +1329,7 @@ int b53_vlan_prepare(struct dsa_switch *ds, int port,
1270 if (vlan->vid_end > dev->num_vlans) 1329 if (vlan->vid_end > dev->num_vlans)
1271 return -ERANGE; 1330 return -ERANGE;
1272 1331
1273 b53_enable_vlan(dev, true); 1332 b53_enable_vlan(dev, true, dev->vlan_filtering_enabled);
1274 1333
1275 return 0; 1334 return 0;
1276} 1335}
@@ -1300,7 +1359,7 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
1300 b53_fast_age_vlan(dev, vid); 1359 b53_fast_age_vlan(dev, vid);
1301 } 1360 }
1302 1361
1303 if (pvid) { 1362 if (pvid && !dsa_is_cpu_port(ds, port)) {
1304 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), 1363 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
1305 vlan->vid_end); 1364 vlan->vid_end);
1306 b53_fast_age_vlan(dev, vid); 1365 b53_fast_age_vlan(dev, vid);
@@ -1326,12 +1385,8 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
1326 1385
1327 vl->members &= ~BIT(port); 1386 vl->members &= ~BIT(port);
1328 1387
1329 if (pvid == vid) { 1388 if (pvid == vid)
1330 if (is5325(dev) || is5365(dev)) 1389 pvid = b53_default_pvid(dev);
1331 pvid = 1;
1332 else
1333 pvid = 0;
1334 }
1335 1390
1336 if (untagged && !dsa_is_cpu_port(ds, port)) 1391 if (untagged && !dsa_is_cpu_port(ds, port))
1337 vl->untag &= ~(BIT(port)); 1392 vl->untag &= ~(BIT(port));
@@ -1644,10 +1699,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)
1644 b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan); 1699 b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan);
1645 dev->ports[port].vlan_ctl_mask = pvlan; 1700 dev->ports[port].vlan_ctl_mask = pvlan;
1646 1701
1647 if (is5325(dev) || is5365(dev)) 1702 pvid = b53_default_pvid(dev);
1648 pvid = 1;
1649 else
1650 pvid = 0;
1651 1703
1652 /* Make this port join all VLANs without VLAN entries */ 1704 /* Make this port join all VLANs without VLAN entries */
1653 if (is58xx(dev)) { 1705 if (is58xx(dev)) {
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index ec796482792d..4dc7ee38b258 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -91,6 +91,7 @@ enum {
91struct b53_port { 91struct b53_port {
92 u16 vlan_ctl_mask; 92 u16 vlan_ctl_mask;
93 struct ethtool_eee eee; 93 struct ethtool_eee eee;
94 u16 pvid;
94}; 95};
95 96
96struct b53_vlan { 97struct b53_vlan {
@@ -137,6 +138,8 @@ struct b53_device {
137 138
138 unsigned int num_vlans; 139 unsigned int num_vlans;
139 struct b53_vlan *vlans; 140 struct b53_vlan *vlans;
141 bool vlan_enabled;
142 bool vlan_filtering_enabled;
140 unsigned int num_ports; 143 unsigned int num_ports;
141 struct b53_port *ports; 144 struct b53_port *ports;
142}; 145};
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 361fbde76654..14138d423cf1 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -690,7 +690,7 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
690 * port, the other ones have already been disabled during 690 * port, the other ones have already been disabled during
691 * bcm_sf2_sw_setup 691 * bcm_sf2_sw_setup
692 */ 692 */
693 for (port = 0; port < DSA_MAX_PORTS; port++) { 693 for (port = 0; port < ds->num_ports; port++) {
694 if (dsa_is_user_port(ds, port) || dsa_is_cpu_port(ds, port)) 694 if (dsa_is_user_port(ds, port) || dsa_is_cpu_port(ds, port))
695 bcm_sf2_port_disable(ds, port, NULL); 695 bcm_sf2_port_disable(ds, port, NULL);
696 } 696 }
@@ -726,10 +726,11 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
726{ 726{
727 struct net_device *p = ds->ports[port].cpu_dp->master; 727 struct net_device *p = ds->ports[port].cpu_dp->master;
728 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); 728 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
729 struct ethtool_wolinfo pwol; 729 struct ethtool_wolinfo pwol = { };
730 730
731 /* Get the parent device WoL settings */ 731 /* Get the parent device WoL settings */
732 p->ethtool_ops->get_wol(p, &pwol); 732 if (p->ethtool_ops->get_wol)
733 p->ethtool_ops->get_wol(p, &pwol);
733 734
734 /* Advertise the parent device supported settings */ 735 /* Advertise the parent device supported settings */
735 wol->supported = pwol.supported; 736 wol->supported = pwol.supported;
@@ -750,9 +751,10 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
750 struct net_device *p = ds->ports[port].cpu_dp->master; 751 struct net_device *p = ds->ports[port].cpu_dp->master;
751 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); 752 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
752 s8 cpu_port = ds->ports[port].cpu_dp->index; 753 s8 cpu_port = ds->ports[port].cpu_dp->index;
753 struct ethtool_wolinfo pwol; 754 struct ethtool_wolinfo pwol = { };
754 755
755 p->ethtool_ops->get_wol(p, &pwol); 756 if (p->ethtool_ops->get_wol)
757 p->ethtool_ops->get_wol(p, &pwol);
756 if (wol->wolopts & ~pwol.supported) 758 if (wol->wolopts & ~pwol.supported)
757 return -EINVAL; 759 return -EINVAL;
758 760
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8dca2c949e73..12fd7ce3f1ff 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -261,6 +261,7 @@ static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
261 unsigned int sub_irq; 261 unsigned int sub_irq;
262 unsigned int n; 262 unsigned int n;
263 u16 reg; 263 u16 reg;
264 u16 ctl1;
264 int err; 265 int err;
265 266
266 mutex_lock(&chip->reg_lock); 267 mutex_lock(&chip->reg_lock);
@@ -270,13 +271,28 @@ static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
270 if (err) 271 if (err)
271 goto out; 272 goto out;
272 273
273 for (n = 0; n < chip->g1_irq.nirqs; ++n) { 274 do {
274 if (reg & (1 << n)) { 275 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
275 sub_irq = irq_find_mapping(chip->g1_irq.domain, n); 276 if (reg & (1 << n)) {
276 handle_nested_irq(sub_irq); 277 sub_irq = irq_find_mapping(chip->g1_irq.domain,
277 ++nhandled; 278 n);
279 handle_nested_irq(sub_irq);
280 ++nhandled;
281 }
278 } 282 }
279 } 283
284 mutex_lock(&chip->reg_lock);
285 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
286 if (err)
287 goto unlock;
288 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
289unlock:
290 mutex_unlock(&chip->reg_lock);
291 if (err)
292 goto out;
293 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
294 } while (reg & ctl1);
295
280out: 296out:
281 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); 297 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
282} 298}
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index a70bb1bb90e7..a6eacf2099c3 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2663,11 +2663,6 @@ static int ena_restore_device(struct ena_adapter *adapter)
2663 goto err_device_destroy; 2663 goto err_device_destroy;
2664 } 2664 }
2665 2665
2666 clear_bit(ENA_FLAG_ONGOING_RESET, &adapter->flags);
2667 /* Make sure we don't have a race with AENQ Links state handler */
2668 if (test_bit(ENA_FLAG_LINK_UP, &adapter->flags))
2669 netif_carrier_on(adapter->netdev);
2670
2671 rc = ena_enable_msix_and_set_admin_interrupts(adapter, 2666 rc = ena_enable_msix_and_set_admin_interrupts(adapter,
2672 adapter->num_queues); 2667 adapter->num_queues);
2673 if (rc) { 2668 if (rc) {
@@ -2684,6 +2679,11 @@ static int ena_restore_device(struct ena_adapter *adapter)
2684 } 2679 }
2685 2680
2686 set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags); 2681 set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags);
2682
2683 clear_bit(ENA_FLAG_ONGOING_RESET, &adapter->flags);
2684 if (test_bit(ENA_FLAG_LINK_UP, &adapter->flags))
2685 netif_carrier_on(adapter->netdev);
2686
2687 mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ)); 2687 mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ));
2688 dev_err(&pdev->dev, 2688 dev_err(&pdev->dev,
2689 "Device reset completed successfully, Driver info: %s\n", 2689 "Device reset completed successfully, Driver info: %s\n",
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index dc8b6173d8d8..63870072cbbd 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -45,7 +45,7 @@
45 45
46#define DRV_MODULE_VER_MAJOR 2 46#define DRV_MODULE_VER_MAJOR 2
47#define DRV_MODULE_VER_MINOR 0 47#define DRV_MODULE_VER_MINOR 0
48#define DRV_MODULE_VER_SUBMINOR 2 48#define DRV_MODULE_VER_SUBMINOR 3
49 49
50#define DRV_MODULE_NAME "ena" 50#define DRV_MODULE_NAME "ena"
51#ifndef DRV_MODULE_VERSION 51#ifndef DRV_MODULE_VERSION
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 28c9b0bdf2f6..bc3ac369cbe3 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -134,6 +134,10 @@ static void bcm_sysport_set_rx_csum(struct net_device *dev,
134 134
135 priv->rx_chk_en = !!(wanted & NETIF_F_RXCSUM); 135 priv->rx_chk_en = !!(wanted & NETIF_F_RXCSUM);
136 reg = rxchk_readl(priv, RXCHK_CONTROL); 136 reg = rxchk_readl(priv, RXCHK_CONTROL);
137 /* Clear L2 header checks, which would prevent BPDUs
138 * from being received.
139 */
140 reg &= ~RXCHK_L2_HDR_DIS;
137 if (priv->rx_chk_en) 141 if (priv->rx_chk_en)
138 reg |= RXCHK_EN; 142 reg |= RXCHK_EN;
139 else 143 else
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 2370dc204202..697c2427f2b7 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2098,6 +2098,7 @@ static int fec_enet_get_regs_len(struct net_device *ndev)
2098#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ 2098#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
2099 defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \ 2099 defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
2100 defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST) 2100 defined(CONFIG_ARM64) || defined(CONFIG_COMPILE_TEST)
2101static __u32 fec_enet_register_version = 2;
2101static u32 fec_enet_register_offset[] = { 2102static u32 fec_enet_register_offset[] = {
2102 FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0, 2103 FEC_IEVENT, FEC_IMASK, FEC_R_DES_ACTIVE_0, FEC_X_DES_ACTIVE_0,
2103 FEC_ECNTRL, FEC_MII_DATA, FEC_MII_SPEED, FEC_MIB_CTRLSTAT, FEC_R_CNTRL, 2104 FEC_ECNTRL, FEC_MII_DATA, FEC_MII_SPEED, FEC_MIB_CTRLSTAT, FEC_R_CNTRL,
@@ -2128,6 +2129,7 @@ static u32 fec_enet_register_offset[] = {
2128 IEEE_R_FDXFC, IEEE_R_OCTETS_OK 2129 IEEE_R_FDXFC, IEEE_R_OCTETS_OK
2129}; 2130};
2130#else 2131#else
2132static __u32 fec_enet_register_version = 1;
2131static u32 fec_enet_register_offset[] = { 2133static u32 fec_enet_register_offset[] = {
2132 FEC_ECNTRL, FEC_IEVENT, FEC_IMASK, FEC_IVEC, FEC_R_DES_ACTIVE_0, 2134 FEC_ECNTRL, FEC_IEVENT, FEC_IMASK, FEC_IVEC, FEC_R_DES_ACTIVE_0,
2133 FEC_R_DES_ACTIVE_1, FEC_R_DES_ACTIVE_2, FEC_X_DES_ACTIVE_0, 2135 FEC_R_DES_ACTIVE_1, FEC_R_DES_ACTIVE_2, FEC_X_DES_ACTIVE_0,
@@ -2149,6 +2151,8 @@ static void fec_enet_get_regs(struct net_device *ndev,
2149 u32 *buf = (u32 *)regbuf; 2151 u32 *buf = (u32 *)regbuf;
2150 u32 i, off; 2152 u32 i, off;
2151 2153
2154 regs->version = fec_enet_register_version;
2155
2152 memset(buf, 0, regs->len); 2156 memset(buf, 0, regs->len);
2153 2157
2154 for (i = 0; i < ARRAY_SIZE(fec_enet_register_offset); i++) { 2158 for (i = 0; i < ARRAY_SIZE(fec_enet_register_offset); i++) {
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 3b9e74be5fbd..ac55db065f16 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -3081,6 +3081,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
3081 dsaf_dev = dev_get_drvdata(&pdev->dev); 3081 dsaf_dev = dev_get_drvdata(&pdev->dev);
3082 if (!dsaf_dev) { 3082 if (!dsaf_dev) {
3083 dev_err(&pdev->dev, "dsaf_dev is NULL\n"); 3083 dev_err(&pdev->dev, "dsaf_dev is NULL\n");
3084 put_device(&pdev->dev);
3084 return -ENODEV; 3085 return -ENODEV;
3085 } 3086 }
3086 3087
@@ -3088,6 +3089,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
3088 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { 3089 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) {
3089 dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n", 3090 dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n",
3090 dsaf_dev->ae_dev.name); 3091 dsaf_dev->ae_dev.name);
3092 put_device(&pdev->dev);
3091 return -ENODEV; 3093 return -ENODEV;
3092 } 3094 }
3093 3095
@@ -3126,6 +3128,9 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)
3126 dsaf_set_bit(credit, DSAF_SBM_ROCEE_CFG_CRD_EN_B, 1); 3128 dsaf_set_bit(credit, DSAF_SBM_ROCEE_CFG_CRD_EN_B, 1);
3127 dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit); 3129 dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit);
3128 } 3130 }
3131
3132 put_device(&pdev->dev);
3133
3129 return 0; 3134 return 0;
3130} 3135}
3131EXPORT_SYMBOL(hns_dsaf_roce_reset); 3136EXPORT_SYMBOL(hns_dsaf_roce_reset);
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 2f427271a793..292a668ce88e 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2879,7 +2879,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2879 2879
2880 ret = mv643xx_eth_shared_of_probe(pdev); 2880 ret = mv643xx_eth_shared_of_probe(pdev);
2881 if (ret) 2881 if (ret)
2882 return ret; 2882 goto err_put_clk;
2883 pd = dev_get_platdata(&pdev->dev); 2883 pd = dev_get_platdata(&pdev->dev);
2884 2884
2885 msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ? 2885 msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
@@ -2887,6 +2887,11 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2887 infer_hw_params(msp); 2887 infer_hw_params(msp);
2888 2888
2889 return 0; 2889 return 0;
2890
2891err_put_clk:
2892 if (!IS_ERR(msp->clk))
2893 clk_disable_unprepare(msp->clk);
2894 return ret;
2890} 2895}
2891 2896
2892static int mv643xx_eth_shared_remove(struct platform_device *pdev) 2897static int mv643xx_eth_shared_remove(struct platform_device *pdev)
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index f3a5fa84860f..57727fe1501e 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -5073,7 +5073,7 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5073 INIT_WORK(&hw->restart_work, sky2_restart); 5073 INIT_WORK(&hw->restart_work, sky2_restart);
5074 5074
5075 pci_set_drvdata(pdev, hw); 5075 pci_set_drvdata(pdev, hw);
5076 pdev->d3_delay = 200; 5076 pdev->d3_delay = 300;
5077 5077
5078 return 0; 5078 return 0;
5079 5079
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 6b88881b8e35..c1438ae52a11 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -3360,7 +3360,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
3360 dev->addr_len = ETH_ALEN; 3360 dev->addr_len = ETH_ALEN;
3361 mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]); 3361 mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]);
3362 if (!is_valid_ether_addr(dev->dev_addr)) { 3362 if (!is_valid_ether_addr(dev->dev_addr)) {
3363 en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n", 3363 en_err(priv, "Port: %d, invalid mac burned: %pM, quitting\n",
3364 priv->port, dev->dev_addr); 3364 priv->port, dev->dev_addr);
3365 err = -EINVAL; 3365 err = -EINVAL;
3366 goto out; 3366 goto out;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 9a0881cb7f51..6c01314e87b0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -617,6 +617,8 @@ static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
617} 617}
618#endif 618#endif
619 619
620#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN)
621
620/* We reach this function only after checking that any of 622/* We reach this function only after checking that any of
621 * the (IPv4 | IPv6) bits are set in cqe->status. 623 * the (IPv4 | IPv6) bits are set in cqe->status.
622 */ 624 */
@@ -624,9 +626,20 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va,
624 netdev_features_t dev_features) 626 netdev_features_t dev_features)
625{ 627{
626 __wsum hw_checksum = 0; 628 __wsum hw_checksum = 0;
629 void *hdr;
630
631 /* CQE csum doesn't cover padding octets in short ethernet
632 * frames. And the pad field is appended prior to calculating
633 * and appending the FCS field.
634 *
635 * Detecting these padded frames requires to verify and parse
636 * IP headers, so we simply force all those small frames to skip
637 * checksum complete.
638 */
639 if (short_frame(skb->len))
640 return -EINVAL;
627 641
628 void *hdr = (u8 *)va + sizeof(struct ethhdr); 642 hdr = (u8 *)va + sizeof(struct ethhdr);
629
630 hw_checksum = csum_unfold((__force __sum16)cqe->checksum); 643 hw_checksum = csum_unfold((__force __sum16)cqe->checksum);
631 644
632 if (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_CVLAN_PRESENT_MASK) && 645 if (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_CVLAN_PRESENT_MASK) &&
@@ -819,6 +832,11 @@ xdp_drop_no_cnt:
819 skb_record_rx_queue(skb, cq_ring); 832 skb_record_rx_queue(skb, cq_ring);
820 833
821 if (likely(dev->features & NETIF_F_RXCSUM)) { 834 if (likely(dev->features & NETIF_F_RXCSUM)) {
835 /* TODO: For IP non TCP/UDP packets when csum complete is
836 * not an option (not supported or any other reason) we can
837 * actually check cqe IPOK status bit and report
838 * CHECKSUM_UNNECESSARY rather than CHECKSUM_NONE
839 */
822 if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_TCP | 840 if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_TCP |
823 MLX4_CQE_STATUS_UDP)) && 841 MLX4_CQE_STATUS_UDP)) &&
824 (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) && 842 (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) &&
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 3e0fa8a8077b..e267ff93e8a8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1583,6 +1583,24 @@ no_trig:
1583 spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags); 1583 spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags);
1584} 1584}
1585 1585
1586void mlx5_cmd_flush(struct mlx5_core_dev *dev)
1587{
1588 struct mlx5_cmd *cmd = &dev->cmd;
1589 int i;
1590
1591 for (i = 0; i < cmd->max_reg_cmds; i++)
1592 while (down_trylock(&cmd->sem))
1593 mlx5_cmd_trigger_completions(dev);
1594
1595 while (down_trylock(&cmd->pages_sem))
1596 mlx5_cmd_trigger_completions(dev);
1597
1598 /* Unlock cmdif */
1599 up(&cmd->pages_sem);
1600 for (i = 0; i < cmd->max_reg_cmds; i++)
1601 up(&cmd->sem);
1602}
1603
1586static int status_to_err(u8 status) 1604static int status_to_err(u8 status)
1587{ 1605{
1588 return status ? -1 : 0; /* TBD more meaningful codes */ 1606 return status ? -1 : 0; /* TBD more meaningful codes */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 8fa8fdd30b85..448a92561567 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -657,6 +657,7 @@ struct mlx5e_channel_stats {
657enum { 657enum {
658 MLX5E_STATE_OPENED, 658 MLX5E_STATE_OPENED,
659 MLX5E_STATE_DESTROYING, 659 MLX5E_STATE_DESTROYING,
660 MLX5E_STATE_XDP_TX_ENABLED,
660}; 661};
661 662
662struct mlx5e_rqt { 663struct mlx5e_rqt {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
index 3740177eed09..03b2a9f9c589 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
@@ -365,7 +365,8 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
365 int sq_num; 365 int sq_num;
366 int i; 366 int i;
367 367
368 if (unlikely(!test_bit(MLX5E_STATE_OPENED, &priv->state))) 368 /* this flag is sufficient, no need to test internal sq state */
369 if (unlikely(!mlx5e_xdp_tx_is_enabled(priv)))
369 return -ENETDOWN; 370 return -ENETDOWN;
370 371
371 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) 372 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
@@ -378,9 +379,6 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
378 379
379 sq = &priv->channels.c[sq_num]->xdpsq; 380 sq = &priv->channels.c[sq_num]->xdpsq;
380 381
381 if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
382 return -ENETDOWN;
383
384 for (i = 0; i < n; i++) { 382 for (i = 0; i < n; i++) {
385 struct xdp_frame *xdpf = frames[i]; 383 struct xdp_frame *xdpf = frames[i];
386 struct mlx5e_xdp_info xdpi; 384 struct mlx5e_xdp_info xdpi;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
index 3a67cb3cd179..ee27a7c8cd87 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
@@ -50,6 +50,23 @@ void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq);
50int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, 50int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
51 u32 flags); 51 u32 flags);
52 52
53static inline void mlx5e_xdp_tx_enable(struct mlx5e_priv *priv)
54{
55 set_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
56}
57
58static inline void mlx5e_xdp_tx_disable(struct mlx5e_priv *priv)
59{
60 clear_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
61 /* let other device's napi(s) see our new state */
62 synchronize_rcu();
63}
64
65static inline bool mlx5e_xdp_tx_is_enabled(struct mlx5e_priv *priv)
66{
67 return test_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
68}
69
53static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_xdpsq *sq) 70static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_xdpsq *sq)
54{ 71{
55 if (sq->doorbell_cseg) { 72 if (sq->doorbell_cseg) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 3bbccead2f63..47233b9a4f81 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -354,9 +354,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
354 354
355 new_channels.params = priv->channels.params; 355 new_channels.params = priv->channels.params;
356 new_channels.params.num_channels = count; 356 new_channels.params.num_channels = count;
357 if (!netif_is_rxfh_configured(priv->netdev))
358 mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
359 MLX5E_INDIR_RQT_SIZE, count);
360 357
361 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { 358 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
362 priv->channels.params = new_channels.params; 359 priv->channels.params = new_channels.params;
@@ -372,6 +369,10 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
372 if (arfs_enabled) 369 if (arfs_enabled)
373 mlx5e_arfs_disable(priv); 370 mlx5e_arfs_disable(priv);
374 371
372 if (!netif_is_rxfh_configured(priv->netdev))
373 mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
374 MLX5E_INDIR_RQT_SIZE, count);
375
375 /* Switch to new channels, set new parameters and close old ones */ 376 /* Switch to new channels, set new parameters and close old ones */
376 mlx5e_switch_priv_channels(priv, &new_channels, NULL); 377 mlx5e_switch_priv_channels(priv, &new_channels, NULL);
377 378
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 01819e5c9975..93e50ccd44c3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2938,6 +2938,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
2938 2938
2939 mlx5e_build_tx2sq_maps(priv); 2939 mlx5e_build_tx2sq_maps(priv);
2940 mlx5e_activate_channels(&priv->channels); 2940 mlx5e_activate_channels(&priv->channels);
2941 mlx5e_xdp_tx_enable(priv);
2941 netif_tx_start_all_queues(priv->netdev); 2942 netif_tx_start_all_queues(priv->netdev);
2942 2943
2943 if (mlx5e_is_vport_rep(priv)) 2944 if (mlx5e_is_vport_rep(priv))
@@ -2959,6 +2960,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
2959 */ 2960 */
2960 netif_tx_stop_all_queues(priv->netdev); 2961 netif_tx_stop_all_queues(priv->netdev);
2961 netif_tx_disable(priv->netdev); 2962 netif_tx_disable(priv->netdev);
2963 mlx5e_xdp_tx_disable(priv);
2962 mlx5e_deactivate_channels(&priv->channels); 2964 mlx5e_deactivate_channels(&priv->channels);
2963} 2965}
2964 2966
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/events.c b/drivers/net/ethernet/mellanox/mlx5/core/events.c
index fbc42b7252a9..503035469d2d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/events.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c
@@ -211,11 +211,10 @@ static int port_module(struct notifier_block *nb, unsigned long type, void *data
211 enum port_module_event_status_type module_status; 211 enum port_module_event_status_type module_status;
212 enum port_module_event_error_type error_type; 212 enum port_module_event_error_type error_type;
213 struct mlx5_eqe_port_module *module_event_eqe; 213 struct mlx5_eqe_port_module *module_event_eqe;
214 const char *status_str, *error_str; 214 const char *status_str;
215 u8 module_num; 215 u8 module_num;
216 216
217 module_event_eqe = &eqe->data.port_module; 217 module_event_eqe = &eqe->data.port_module;
218 module_num = module_event_eqe->module;
219 module_status = module_event_eqe->module_status & 218 module_status = module_event_eqe->module_status &
220 PORT_MODULE_EVENT_MODULE_STATUS_MASK; 219 PORT_MODULE_EVENT_MODULE_STATUS_MASK;
221 error_type = module_event_eqe->error_type & 220 error_type = module_event_eqe->error_type &
@@ -223,25 +222,27 @@ static int port_module(struct notifier_block *nb, unsigned long type, void *data
223 222
224 if (module_status < MLX5_MODULE_STATUS_NUM) 223 if (module_status < MLX5_MODULE_STATUS_NUM)
225 events->pme_stats.status_counters[module_status]++; 224 events->pme_stats.status_counters[module_status]++;
226 status_str = mlx5_pme_status_to_string(module_status);
227 225
228 if (module_status == MLX5_MODULE_STATUS_ERROR) { 226 if (module_status == MLX5_MODULE_STATUS_ERROR)
229 if (error_type < MLX5_MODULE_EVENT_ERROR_NUM) 227 if (error_type < MLX5_MODULE_EVENT_ERROR_NUM)
230 events->pme_stats.error_counters[error_type]++; 228 events->pme_stats.error_counters[error_type]++;
231 error_str = mlx5_pme_error_to_string(error_type);
232 }
233 229
234 if (!printk_ratelimit()) 230 if (!printk_ratelimit())
235 return NOTIFY_OK; 231 return NOTIFY_OK;
236 232
237 if (module_status == MLX5_MODULE_STATUS_ERROR) 233 module_num = module_event_eqe->module;
234 status_str = mlx5_pme_status_to_string(module_status);
235 if (module_status == MLX5_MODULE_STATUS_ERROR) {
236 const char *error_str = mlx5_pme_error_to_string(error_type);
237
238 mlx5_core_err(events->dev, 238 mlx5_core_err(events->dev,
239 "Port module event[error]: module %u, %s, %s\n", 239 "Port module event[error]: module %u, %s, %s\n",
240 module_num, status_str, error_str); 240 module_num, status_str, error_str);
241 else 241 } else {
242 mlx5_core_info(events->dev, 242 mlx5_core_info(events->dev,
243 "Port module event: module %u, %s\n", 243 "Port module event: module %u, %s\n",
244 module_num, status_str); 244 module_num, status_str);
245 }
245 246
246 return NOTIFY_OK; 247 return NOTIFY_OK;
247} 248}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 196c07383082..cb9fa3430c53 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -103,7 +103,7 @@ void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force)
103 mlx5_core_err(dev, "start\n"); 103 mlx5_core_err(dev, "start\n");
104 if (pci_channel_offline(dev->pdev) || in_fatal(dev) || force) { 104 if (pci_channel_offline(dev->pdev) || in_fatal(dev) || force) {
105 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; 105 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
106 mlx5_cmd_trigger_completions(dev); 106 mlx5_cmd_flush(dev);
107 } 107 }
108 108
109 mlx5_notifier_call_chain(dev->priv.events, MLX5_DEV_EVENT_SYS_ERROR, (void *)1); 109 mlx5_notifier_call_chain(dev->priv.events, MLX5_DEV_EVENT_SYS_ERROR, (void *)1);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 5300b0b6d836..4fdac020b795 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -126,6 +126,7 @@ u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev,
126 struct ptp_system_timestamp *sts); 126 struct ptp_system_timestamp *sts);
127 127
128void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev); 128void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev);
129void mlx5_cmd_flush(struct mlx5_core_dev *dev);
129int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev); 130int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev);
130void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev); 131void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
131 132
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 32519c93df17..b65e274b02e9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -862,8 +862,9 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
862 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 862 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
863 bool configure = false; 863 bool configure = false;
864 bool pfc = false; 864 bool pfc = false;
865 u16 thres_cells;
866 u16 delay_cells;
865 bool lossy; 867 bool lossy;
866 u16 thres;
867 868
868 for (j = 0; j < IEEE_8021QAZ_MAX_TCS; j++) { 869 for (j = 0; j < IEEE_8021QAZ_MAX_TCS; j++) {
869 if (prio_tc[j] == i) { 870 if (prio_tc[j] == i) {
@@ -877,10 +878,11 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
877 continue; 878 continue;
878 879
879 lossy = !(pfc || pause_en); 880 lossy = !(pfc || pause_en);
880 thres = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu); 881 thres_cells = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu);
881 delay = mlxsw_sp_pg_buf_delay_get(mlxsw_sp, mtu, delay, pfc, 882 delay_cells = mlxsw_sp_pg_buf_delay_get(mlxsw_sp, mtu, delay,
882 pause_en); 883 pfc, pause_en);
883 mlxsw_sp_pg_buf_pack(pbmc_pl, i, thres + delay, thres, lossy); 884 mlxsw_sp_pg_buf_pack(pbmc_pl, i, thres_cells + delay_cells,
885 thres_cells, lossy);
884 } 886 }
885 887
886 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pbmc), pbmc_pl); 888 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pbmc), pbmc_pl);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index beb8e5d6401a..ded556b7bab5 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -1688,6 +1688,15 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn,
1688 1688
1689 eth_hlen = ETH_HLEN + (vlan_valid ? sizeof(u32) : 0); 1689 eth_hlen = ETH_HLEN + (vlan_valid ? sizeof(u32) : 0);
1690 1690
1691 if (!ether_addr_equal(ethh->h_dest,
1692 p_hwfn->p_rdma_info->iwarp.mac_addr)) {
1693 DP_VERBOSE(p_hwfn,
1694 QED_MSG_RDMA,
1695 "Got unexpected mac %pM instead of %pM\n",
1696 ethh->h_dest, p_hwfn->p_rdma_info->iwarp.mac_addr);
1697 return -EINVAL;
1698 }
1699
1691 ether_addr_copy(remote_mac_addr, ethh->h_source); 1700 ether_addr_copy(remote_mac_addr, ethh->h_source);
1692 ether_addr_copy(local_mac_addr, ethh->h_dest); 1701 ether_addr_copy(local_mac_addr, ethh->h_dest);
1693 1702
@@ -2605,7 +2614,7 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
2605 struct qed_iwarp_info *iwarp_info; 2614 struct qed_iwarp_info *iwarp_info;
2606 struct qed_ll2_acquire_data data; 2615 struct qed_ll2_acquire_data data;
2607 struct qed_ll2_cbs cbs; 2616 struct qed_ll2_cbs cbs;
2608 u32 mpa_buff_size; 2617 u32 buff_size;
2609 u16 n_ooo_bufs; 2618 u16 n_ooo_bufs;
2610 int rc = 0; 2619 int rc = 0;
2611 int i; 2620 int i;
@@ -2632,7 +2641,7 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
2632 2641
2633 memset(&data, 0, sizeof(data)); 2642 memset(&data, 0, sizeof(data));
2634 data.input.conn_type = QED_LL2_TYPE_IWARP; 2643 data.input.conn_type = QED_LL2_TYPE_IWARP;
2635 data.input.mtu = QED_IWARP_MAX_SYN_PKT_SIZE; 2644 data.input.mtu = params->max_mtu;
2636 data.input.rx_num_desc = QED_IWARP_LL2_SYN_RX_SIZE; 2645 data.input.rx_num_desc = QED_IWARP_LL2_SYN_RX_SIZE;
2637 data.input.tx_num_desc = QED_IWARP_LL2_SYN_TX_SIZE; 2646 data.input.tx_num_desc = QED_IWARP_LL2_SYN_TX_SIZE;
2638 data.input.tx_max_bds_per_packet = 1; /* will never be fragmented */ 2647 data.input.tx_max_bds_per_packet = 1; /* will never be fragmented */
@@ -2654,9 +2663,10 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
2654 goto err; 2663 goto err;
2655 } 2664 }
2656 2665
2666 buff_size = QED_IWARP_MAX_BUF_SIZE(params->max_mtu);
2657 rc = qed_iwarp_ll2_alloc_buffers(p_hwfn, 2667 rc = qed_iwarp_ll2_alloc_buffers(p_hwfn,
2658 QED_IWARP_LL2_SYN_RX_SIZE, 2668 QED_IWARP_LL2_SYN_RX_SIZE,
2659 QED_IWARP_MAX_SYN_PKT_SIZE, 2669 buff_size,
2660 iwarp_info->ll2_syn_handle); 2670 iwarp_info->ll2_syn_handle);
2661 if (rc) 2671 if (rc)
2662 goto err; 2672 goto err;
@@ -2710,10 +2720,9 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
2710 if (rc) 2720 if (rc)
2711 goto err; 2721 goto err;
2712 2722
2713 mpa_buff_size = QED_IWARP_MAX_BUF_SIZE(params->max_mtu);
2714 rc = qed_iwarp_ll2_alloc_buffers(p_hwfn, 2723 rc = qed_iwarp_ll2_alloc_buffers(p_hwfn,
2715 data.input.rx_num_desc, 2724 data.input.rx_num_desc,
2716 mpa_buff_size, 2725 buff_size,
2717 iwarp_info->ll2_mpa_handle); 2726 iwarp_info->ll2_mpa_handle);
2718 if (rc) 2727 if (rc)
2719 goto err; 2728 goto err;
@@ -2726,7 +2735,7 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
2726 2735
2727 iwarp_info->max_num_partial_fpdus = (u16)p_hwfn->p_rdma_info->num_qps; 2736 iwarp_info->max_num_partial_fpdus = (u16)p_hwfn->p_rdma_info->num_qps;
2728 2737
2729 iwarp_info->mpa_intermediate_buf = kzalloc(mpa_buff_size, GFP_KERNEL); 2738 iwarp_info->mpa_intermediate_buf = kzalloc(buff_size, GFP_KERNEL);
2730 if (!iwarp_info->mpa_intermediate_buf) 2739 if (!iwarp_info->mpa_intermediate_buf)
2731 goto err; 2740 goto err;
2732 2741
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.h b/drivers/net/ethernet/qlogic/qed/qed_iwarp.h
index b8f612d00241..7ac959038324 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.h
@@ -46,7 +46,6 @@ enum qed_iwarp_qp_state qed_roce2iwarp_state(enum qed_roce_qp_state state);
46 46
47#define QED_IWARP_LL2_SYN_TX_SIZE (128) 47#define QED_IWARP_LL2_SYN_TX_SIZE (128)
48#define QED_IWARP_LL2_SYN_RX_SIZE (256) 48#define QED_IWARP_LL2_SYN_RX_SIZE (256)
49#define QED_IWARP_MAX_SYN_PKT_SIZE (128)
50 49
51#define QED_IWARP_LL2_OOO_DEF_TX_SIZE (256) 50#define QED_IWARP_LL2_OOO_DEF_TX_SIZE (256)
52#define QED_IWARP_MAX_OOO (16) 51#define QED_IWARP_MAX_OOO (16)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index abb94c543aa2..6e36b88ca7c9 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1286,11 +1286,13 @@ static u16 rtl_get_events(struct rtl8169_private *tp)
1286static void rtl_ack_events(struct rtl8169_private *tp, u16 bits) 1286static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
1287{ 1287{
1288 RTL_W16(tp, IntrStatus, bits); 1288 RTL_W16(tp, IntrStatus, bits);
1289 mmiowb();
1289} 1290}
1290 1291
1291static void rtl_irq_disable(struct rtl8169_private *tp) 1292static void rtl_irq_disable(struct rtl8169_private *tp)
1292{ 1293{
1293 RTL_W16(tp, IntrMask, 0); 1294 RTL_W16(tp, IntrMask, 0);
1295 mmiowb();
1294} 1296}
1295 1297
1296#define RTL_EVENT_NAPI_RX (RxOK | RxErr) 1298#define RTL_EVENT_NAPI_RX (RxOK | RxErr)
@@ -6072,7 +6074,6 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
6072 struct device *d = tp_to_dev(tp); 6074 struct device *d = tp_to_dev(tp);
6073 dma_addr_t mapping; 6075 dma_addr_t mapping;
6074 u32 opts[2], len; 6076 u32 opts[2], len;
6075 bool stop_queue;
6076 int frags; 6077 int frags;
6077 6078
6078 if (unlikely(!rtl_tx_slots_avail(tp, skb_shinfo(skb)->nr_frags))) { 6079 if (unlikely(!rtl_tx_slots_avail(tp, skb_shinfo(skb)->nr_frags))) {
@@ -6114,6 +6115,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
6114 6115
6115 txd->opts2 = cpu_to_le32(opts[1]); 6116 txd->opts2 = cpu_to_le32(opts[1]);
6116 6117
6118 netdev_sent_queue(dev, skb->len);
6119
6117 skb_tx_timestamp(skb); 6120 skb_tx_timestamp(skb);
6118 6121
6119 /* Force memory writes to complete before releasing descriptor */ 6122 /* Force memory writes to complete before releasing descriptor */
@@ -6126,14 +6129,16 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
6126 6129
6127 tp->cur_tx += frags + 1; 6130 tp->cur_tx += frags + 1;
6128 6131
6129 stop_queue = !rtl_tx_slots_avail(tp, MAX_SKB_FRAGS); 6132 RTL_W8(tp, TxPoll, NPQ);
6130 if (unlikely(stop_queue))
6131 netif_stop_queue(dev);
6132 6133
6133 if (__netdev_sent_queue(dev, skb->len, skb->xmit_more)) 6134 mmiowb();
6134 RTL_W8(tp, TxPoll, NPQ);
6135 6135
6136 if (unlikely(stop_queue)) { 6136 if (!rtl_tx_slots_avail(tp, MAX_SKB_FRAGS)) {
6137 /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
6138 * not miss a ring update when it notices a stopped queue.
6139 */
6140 smp_wmb();
6141 netif_stop_queue(dev);
6137 /* Sync with rtl_tx: 6142 /* Sync with rtl_tx:
6138 * - publish queue status and cur_tx ring index (write barrier) 6143 * - publish queue status and cur_tx ring index (write barrier)
6139 * - refresh dirty_tx ring index (read barrier). 6144 * - refresh dirty_tx ring index (read barrier).
@@ -6483,7 +6488,9 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
6483 6488
6484 if (work_done < budget) { 6489 if (work_done < budget) {
6485 napi_complete_done(napi, work_done); 6490 napi_complete_done(napi, work_done);
6491
6486 rtl_irq_enable(tp); 6492 rtl_irq_enable(tp);
6493 mmiowb();
6487 } 6494 }
6488 6495
6489 return work_done; 6496 return work_done;
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 2f2bda68d861..c08034154a9a 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -6115,7 +6115,7 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
6115static int efx_ef10_mtd_probe(struct efx_nic *efx) 6115static int efx_ef10_mtd_probe(struct efx_nic *efx)
6116{ 6116{
6117 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX); 6117 MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX);
6118 DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT); 6118 DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT) = { 0 };
6119 struct efx_mcdi_mtd_partition *parts; 6119 struct efx_mcdi_mtd_partition *parts;
6120 size_t outlen, n_parts_total, i, n_parts; 6120 size_t outlen, n_parts_total, i, n_parts;
6121 unsigned int type; 6121 unsigned int type;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index 20299f6f65fc..736e29635b77 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -241,15 +241,18 @@ static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
241static int dwmac4_rx_check_timestamp(void *desc) 241static int dwmac4_rx_check_timestamp(void *desc)
242{ 242{
243 struct dma_desc *p = (struct dma_desc *)desc; 243 struct dma_desc *p = (struct dma_desc *)desc;
244 unsigned int rdes0 = le32_to_cpu(p->des0);
245 unsigned int rdes1 = le32_to_cpu(p->des1);
246 unsigned int rdes3 = le32_to_cpu(p->des3);
244 u32 own, ctxt; 247 u32 own, ctxt;
245 int ret = 1; 248 int ret = 1;
246 249
247 own = p->des3 & RDES3_OWN; 250 own = rdes3 & RDES3_OWN;
248 ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR) 251 ctxt = ((rdes3 & RDES3_CONTEXT_DESCRIPTOR)
249 >> RDES3_CONTEXT_DESCRIPTOR_SHIFT); 252 >> RDES3_CONTEXT_DESCRIPTOR_SHIFT);
250 253
251 if (likely(!own && ctxt)) { 254 if (likely(!own && ctxt)) {
252 if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff)) 255 if ((rdes0 == 0xffffffff) && (rdes1 == 0xffffffff))
253 /* Corrupted value */ 256 /* Corrupted value */
254 ret = -EINVAL; 257 ret = -EINVAL;
255 else 258 else
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 5d85742a2be0..3c749c327cbd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -696,25 +696,27 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev,
696 struct ethtool_eee *edata) 696 struct ethtool_eee *edata)
697{ 697{
698 struct stmmac_priv *priv = netdev_priv(dev); 698 struct stmmac_priv *priv = netdev_priv(dev);
699 int ret;
699 700
700 priv->eee_enabled = edata->eee_enabled; 701 if (!edata->eee_enabled) {
701
702 if (!priv->eee_enabled)
703 stmmac_disable_eee_mode(priv); 702 stmmac_disable_eee_mode(priv);
704 else { 703 } else {
705 /* We are asking for enabling the EEE but it is safe 704 /* We are asking for enabling the EEE but it is safe
706 * to verify all by invoking the eee_init function. 705 * to verify all by invoking the eee_init function.
707 * In case of failure it will return an error. 706 * In case of failure it will return an error.
708 */ 707 */
709 priv->eee_enabled = stmmac_eee_init(priv); 708 edata->eee_enabled = stmmac_eee_init(priv);
710 if (!priv->eee_enabled) 709 if (!edata->eee_enabled)
711 return -EOPNOTSUPP; 710 return -EOPNOTSUPP;
712
713 /* Do not change tx_lpi_timer in case of failure */
714 priv->tx_lpi_timer = edata->tx_lpi_timer;
715 } 711 }
716 712
717 return phy_ethtool_set_eee(dev->phydev, edata); 713 ret = phy_ethtool_set_eee(dev->phydev, edata);
714 if (ret)
715 return ret;
716
717 priv->eee_enabled = edata->eee_enabled;
718 priv->tx_lpi_timer = edata->tx_lpi_timer;
719 return 0;
718} 720}
719 721
720static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv) 722static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv)
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 1f612268c998..d847f672a705 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -259,7 +259,7 @@ static int netcp_module_probe(struct netcp_device *netcp_device,
259 const char *name; 259 const char *name;
260 char node_name[32]; 260 char node_name[32];
261 261
262 if (of_property_read_string(node, "label", &name) < 0) { 262 if (of_property_read_string(child, "label", &name) < 0) {
263 snprintf(node_name, sizeof(node_name), "%pOFn", child); 263 snprintf(node_name, sizeof(node_name), "%pOFn", child);
264 name = node_name; 264 name = node_name;
265 } 265 }
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 189cd2048c3a..c5675df5fc6f 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -553,7 +553,7 @@ int phy_start_aneg(struct phy_device *phydev)
553 if (err < 0) 553 if (err < 0)
554 goto out_unlock; 554 goto out_unlock;
555 555
556 if (__phy_is_started(phydev)) { 556 if (phy_is_started(phydev)) {
557 if (phydev->autoneg == AUTONEG_ENABLE) { 557 if (phydev->autoneg == AUTONEG_ENABLE) {
558 err = phy_check_link_status(phydev); 558 err = phy_check_link_status(phydev);
559 } else { 559 } else {
@@ -709,7 +709,7 @@ void phy_stop_machine(struct phy_device *phydev)
709 cancel_delayed_work_sync(&phydev->state_queue); 709 cancel_delayed_work_sync(&phydev->state_queue);
710 710
711 mutex_lock(&phydev->lock); 711 mutex_lock(&phydev->lock);
712 if (__phy_is_started(phydev)) 712 if (phy_is_started(phydev))
713 phydev->state = PHY_UP; 713 phydev->state = PHY_UP;
714 mutex_unlock(&phydev->lock); 714 mutex_unlock(&phydev->lock);
715} 715}
@@ -762,9 +762,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
762{ 762{
763 struct phy_device *phydev = phy_dat; 763 struct phy_device *phydev = phy_dat;
764 764
765 if (!phy_is_started(phydev))
766 return IRQ_NONE; /* It can't be ours. */
767
768 if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev)) 765 if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev))
769 return IRQ_NONE; 766 return IRQ_NONE;
770 767
@@ -842,15 +839,14 @@ EXPORT_SYMBOL(phy_stop_interrupts);
842 */ 839 */
843void phy_stop(struct phy_device *phydev) 840void phy_stop(struct phy_device *phydev)
844{ 841{
845 mutex_lock(&phydev->lock); 842 if (!phy_is_started(phydev)) {
846
847 if (!__phy_is_started(phydev)) {
848 WARN(1, "called from state %s\n", 843 WARN(1, "called from state %s\n",
849 phy_state_to_str(phydev->state)); 844 phy_state_to_str(phydev->state));
850 mutex_unlock(&phydev->lock);
851 return; 845 return;
852 } 846 }
853 847
848 mutex_lock(&phydev->lock);
849
854 if (phy_interrupt_is_valid(phydev)) 850 if (phy_interrupt_is_valid(phydev))
855 phy_disable_interrupts(phydev); 851 phy_disable_interrupts(phydev);
856 852
@@ -989,8 +985,10 @@ void phy_state_machine(struct work_struct *work)
989 * state machine would be pointless and possibly error prone when 985 * state machine would be pointless and possibly error prone when
990 * called from phy_disconnect() synchronously. 986 * called from phy_disconnect() synchronously.
991 */ 987 */
988 mutex_lock(&phydev->lock);
992 if (phy_polling_mode(phydev) && phy_is_started(phydev)) 989 if (phy_polling_mode(phydev) && phy_is_started(phydev))
993 phy_queue_state_machine(phydev, PHY_STATE_TIME); 990 phy_queue_state_machine(phydev, PHY_STATE_TIME);
991 mutex_unlock(&phydev->lock);
994} 992}
995 993
996/** 994/**
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e7becc7379d7..938803237d7f 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -474,6 +474,17 @@ static void phylink_run_resolve(struct phylink *pl)
474 queue_work(system_power_efficient_wq, &pl->resolve); 474 queue_work(system_power_efficient_wq, &pl->resolve);
475} 475}
476 476
477static void phylink_run_resolve_and_disable(struct phylink *pl, int bit)
478{
479 unsigned long state = pl->phylink_disable_state;
480
481 set_bit(bit, &pl->phylink_disable_state);
482 if (state == 0) {
483 queue_work(system_power_efficient_wq, &pl->resolve);
484 flush_work(&pl->resolve);
485 }
486}
487
477static void phylink_fixed_poll(struct timer_list *t) 488static void phylink_fixed_poll(struct timer_list *t)
478{ 489{
479 struct phylink *pl = container_of(t, struct phylink, link_poll); 490 struct phylink *pl = container_of(t, struct phylink, link_poll);
@@ -924,9 +935,7 @@ void phylink_stop(struct phylink *pl)
924 if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) 935 if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
925 del_timer_sync(&pl->link_poll); 936 del_timer_sync(&pl->link_poll);
926 937
927 set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); 938 phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_STOPPED);
928 queue_work(system_power_efficient_wq, &pl->resolve);
929 flush_work(&pl->resolve);
930} 939}
931EXPORT_SYMBOL_GPL(phylink_stop); 940EXPORT_SYMBOL_GPL(phylink_stop);
932 941
@@ -1632,9 +1641,7 @@ static void phylink_sfp_link_down(void *upstream)
1632 1641
1633 ASSERT_RTNL(); 1642 ASSERT_RTNL();
1634 1643
1635 set_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state); 1644 phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_LINK);
1636 queue_work(system_power_efficient_wq, &pl->resolve);
1637 flush_work(&pl->resolve);
1638} 1645}
1639 1646
1640static void phylink_sfp_link_up(void *upstream) 1647static void phylink_sfp_link_up(void *upstream)
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index ad9db652874d..fef701bfad62 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -347,6 +347,7 @@ static int sfp_register_bus(struct sfp_bus *bus)
347 return ret; 347 return ret;
348 } 348 }
349 } 349 }
350 bus->socket_ops->attach(bus->sfp);
350 if (bus->started) 351 if (bus->started)
351 bus->socket_ops->start(bus->sfp); 352 bus->socket_ops->start(bus->sfp);
352 bus->netdev->sfp_bus = bus; 353 bus->netdev->sfp_bus = bus;
@@ -362,6 +363,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
362 if (bus->registered) { 363 if (bus->registered) {
363 if (bus->started) 364 if (bus->started)
364 bus->socket_ops->stop(bus->sfp); 365 bus->socket_ops->stop(bus->sfp);
366 bus->socket_ops->detach(bus->sfp);
365 if (bus->phydev && ops && ops->disconnect_phy) 367 if (bus->phydev && ops && ops->disconnect_phy)
366 ops->disconnect_phy(bus->upstream); 368 ops->disconnect_phy(bus->upstream);
367 } 369 }
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index fd8bb998ae52..68c8fbf099f8 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -184,6 +184,7 @@ struct sfp {
184 184
185 struct gpio_desc *gpio[GPIO_MAX]; 185 struct gpio_desc *gpio[GPIO_MAX];
186 186
187 bool attached;
187 unsigned int state; 188 unsigned int state;
188 struct delayed_work poll; 189 struct delayed_work poll;
189 struct delayed_work timeout; 190 struct delayed_work timeout;
@@ -1475,7 +1476,7 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
1475 */ 1476 */
1476 switch (sfp->sm_mod_state) { 1477 switch (sfp->sm_mod_state) {
1477 default: 1478 default:
1478 if (event == SFP_E_INSERT) { 1479 if (event == SFP_E_INSERT && sfp->attached) {
1479 sfp_module_tx_disable(sfp); 1480 sfp_module_tx_disable(sfp);
1480 sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT); 1481 sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT);
1481 } 1482 }
@@ -1607,6 +1608,19 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
1607 mutex_unlock(&sfp->sm_mutex); 1608 mutex_unlock(&sfp->sm_mutex);
1608} 1609}
1609 1610
1611static void sfp_attach(struct sfp *sfp)
1612{
1613 sfp->attached = true;
1614 if (sfp->state & SFP_F_PRESENT)
1615 sfp_sm_event(sfp, SFP_E_INSERT);
1616}
1617
1618static void sfp_detach(struct sfp *sfp)
1619{
1620 sfp->attached = false;
1621 sfp_sm_event(sfp, SFP_E_REMOVE);
1622}
1623
1610static void sfp_start(struct sfp *sfp) 1624static void sfp_start(struct sfp *sfp)
1611{ 1625{
1612 sfp_sm_event(sfp, SFP_E_DEV_UP); 1626 sfp_sm_event(sfp, SFP_E_DEV_UP);
@@ -1667,6 +1681,8 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
1667} 1681}
1668 1682
1669static const struct sfp_socket_ops sfp_module_ops = { 1683static const struct sfp_socket_ops sfp_module_ops = {
1684 .attach = sfp_attach,
1685 .detach = sfp_detach,
1670 .start = sfp_start, 1686 .start = sfp_start,
1671 .stop = sfp_stop, 1687 .stop = sfp_stop,
1672 .module_info = sfp_module_info, 1688 .module_info = sfp_module_info,
@@ -1834,10 +1850,6 @@ static int sfp_probe(struct platform_device *pdev)
1834 dev_info(sfp->dev, "Host maximum power %u.%uW\n", 1850 dev_info(sfp->dev, "Host maximum power %u.%uW\n",
1835 sfp->max_power_mW / 1000, (sfp->max_power_mW / 100) % 10); 1851 sfp->max_power_mW / 1000, (sfp->max_power_mW / 100) % 10);
1836 1852
1837 sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops);
1838 if (!sfp->sfp_bus)
1839 return -ENOMEM;
1840
1841 /* Get the initial state, and always signal TX disable, 1853 /* Get the initial state, and always signal TX disable,
1842 * since the network interface will not be up. 1854 * since the network interface will not be up.
1843 */ 1855 */
@@ -1848,10 +1860,6 @@ static int sfp_probe(struct platform_device *pdev)
1848 sfp->state |= SFP_F_RATE_SELECT; 1860 sfp->state |= SFP_F_RATE_SELECT;
1849 sfp_set_state(sfp, sfp->state); 1861 sfp_set_state(sfp, sfp->state);
1850 sfp_module_tx_disable(sfp); 1862 sfp_module_tx_disable(sfp);
1851 rtnl_lock();
1852 if (sfp->state & SFP_F_PRESENT)
1853 sfp_sm_event(sfp, SFP_E_INSERT);
1854 rtnl_unlock();
1855 1863
1856 for (i = 0; i < GPIO_MAX; i++) { 1864 for (i = 0; i < GPIO_MAX; i++) {
1857 if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i]) 1865 if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i])
@@ -1884,6 +1892,10 @@ static int sfp_probe(struct platform_device *pdev)
1884 dev_warn(sfp->dev, 1892 dev_warn(sfp->dev,
1885 "No tx_disable pin: SFP modules will always be emitting.\n"); 1893 "No tx_disable pin: SFP modules will always be emitting.\n");
1886 1894
1895 sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops);
1896 if (!sfp->sfp_bus)
1897 return -ENOMEM;
1898
1887 return 0; 1899 return 0;
1888} 1900}
1889 1901
diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h
index 31b0acf337e2..64f54b0bbd8c 100644
--- a/drivers/net/phy/sfp.h
+++ b/drivers/net/phy/sfp.h
@@ -7,6 +7,8 @@
7struct sfp; 7struct sfp;
8 8
9struct sfp_socket_ops { 9struct sfp_socket_ops {
10 void (*attach)(struct sfp *sfp);
11 void (*detach)(struct sfp *sfp);
10 void (*start)(struct sfp *sfp); 12 void (*start)(struct sfp *sfp);
11 void (*stop)(struct sfp *sfp); 13 void (*stop)(struct sfp *sfp);
12 int (*module_info)(struct sfp *sfp, struct ethtool_modinfo *modinfo); 14 int (*module_info)(struct sfp *sfp, struct ethtool_modinfo *modinfo);
diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index 74a8782313cf..bd6084e315de 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -44,7 +44,10 @@ static int xgmiitorgmii_read_status(struct phy_device *phydev)
44 u16 val = 0; 44 u16 val = 0;
45 int err; 45 int err;
46 46
47 err = priv->phy_drv->read_status(phydev); 47 if (priv->phy_drv->read_status)
48 err = priv->phy_drv->read_status(phydev);
49 else
50 err = genphy_read_status(phydev);
48 if (err < 0) 51 if (err < 0)
49 return err; 52 return err;
50 53
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index afd9d25d1992..958f1cf67282 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -256,17 +256,6 @@ static void __team_option_inst_mark_removed_port(struct team *team,
256 } 256 }
257} 257}
258 258
259static bool __team_option_inst_tmp_find(const struct list_head *opts,
260 const struct team_option_inst *needle)
261{
262 struct team_option_inst *opt_inst;
263
264 list_for_each_entry(opt_inst, opts, tmp_list)
265 if (opt_inst == needle)
266 return true;
267 return false;
268}
269
270static int __team_options_register(struct team *team, 259static int __team_options_register(struct team *team,
271 const struct team_option *option, 260 const struct team_option *option,
272 size_t option_count) 261 size_t option_count)
@@ -2460,7 +2449,6 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
2460 int err = 0; 2449 int err = 0;
2461 int i; 2450 int i;
2462 struct nlattr *nl_option; 2451 struct nlattr *nl_option;
2463 LIST_HEAD(opt_inst_list);
2464 2452
2465 rtnl_lock(); 2453 rtnl_lock();
2466 2454
@@ -2480,6 +2468,7 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
2480 struct nlattr *opt_attrs[TEAM_ATTR_OPTION_MAX + 1]; 2468 struct nlattr *opt_attrs[TEAM_ATTR_OPTION_MAX + 1];
2481 struct nlattr *attr; 2469 struct nlattr *attr;
2482 struct nlattr *attr_data; 2470 struct nlattr *attr_data;
2471 LIST_HEAD(opt_inst_list);
2483 enum team_option_type opt_type; 2472 enum team_option_type opt_type;
2484 int opt_port_ifindex = 0; /* != 0 for per-port options */ 2473 int opt_port_ifindex = 0; /* != 0 for per-port options */
2485 u32 opt_array_index = 0; 2474 u32 opt_array_index = 0;
@@ -2584,23 +2573,17 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
2584 if (err) 2573 if (err)
2585 goto team_put; 2574 goto team_put;
2586 opt_inst->changed = true; 2575 opt_inst->changed = true;
2587
2588 /* dumb/evil user-space can send us duplicate opt,
2589 * keep only the last one
2590 */
2591 if (__team_option_inst_tmp_find(&opt_inst_list,
2592 opt_inst))
2593 continue;
2594
2595 list_add(&opt_inst->tmp_list, &opt_inst_list); 2576 list_add(&opt_inst->tmp_list, &opt_inst_list);
2596 } 2577 }
2597 if (!opt_found) { 2578 if (!opt_found) {
2598 err = -ENOENT; 2579 err = -ENOENT;
2599 goto team_put; 2580 goto team_put;
2600 } 2581 }
2601 }
2602 2582
2603 err = team_nl_send_event_options_get(team, &opt_inst_list); 2583 err = team_nl_send_event_options_get(team, &opt_inst_list);
2584 if (err)
2585 break;
2586 }
2604 2587
2605team_put: 2588team_put:
2606 team_nl_team_put(team); 2589 team_nl_team_put(team);
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 735ad838e2ba..18af2f8eee96 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -1201,8 +1201,8 @@ static const struct usb_device_id products[] = {
1201 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ 1201 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
1202 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */ 1202 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
1203 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */ 1203 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
1204 {QMI_FIXED_INTF(0x1199, 0x68c0, 8)}, /* Sierra Wireless MC7304/MC7354 */ 1204 {QMI_QUIRK_SET_DTR(0x1199, 0x68c0, 8)}, /* Sierra Wireless MC7304/MC7354, WP76xx */
1205 {QMI_FIXED_INTF(0x1199, 0x68c0, 10)}, /* Sierra Wireless MC7304/MC7354 */ 1205 {QMI_QUIRK_SET_DTR(0x1199, 0x68c0, 10)},/* Sierra Wireless MC7304/MC7354 */
1206 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */ 1206 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
1207 {QMI_FIXED_INTF(0x1199, 0x901f, 8)}, /* Sierra Wireless EM7355 */ 1207 {QMI_FIXED_INTF(0x1199, 0x901f, 8)}, /* Sierra Wireless EM7355 */
1208 {QMI_FIXED_INTF(0x1199, 0x9041, 8)}, /* Sierra Wireless MC7305/MC7355 */ 1208 {QMI_FIXED_INTF(0x1199, 0x9041, 8)}, /* Sierra Wireless MC7305/MC7355 */
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 60dd1ec1665f..ada6baf8847a 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -557,6 +557,7 @@ enum spd_duplex {
557/* MAC PASSTHRU */ 557/* MAC PASSTHRU */
558#define AD_MASK 0xfee0 558#define AD_MASK 0xfee0
559#define BND_MASK 0x0004 559#define BND_MASK 0x0004
560#define BD_MASK 0x0001
560#define EFUSE 0xcfdb 561#define EFUSE 0xcfdb
561#define PASS_THRU_MASK 0x1 562#define PASS_THRU_MASK 0x1
562 563
@@ -1176,9 +1177,9 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
1176 return -ENODEV; 1177 return -ENODEV;
1177 } 1178 }
1178 } else { 1179 } else {
1179 /* test for RTL8153-BND */ 1180 /* test for RTL8153-BND and RTL8153-BD */
1180 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_MISC_1); 1181 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_MISC_1);
1181 if ((ocp_data & BND_MASK) == 0) { 1182 if ((ocp_data & BND_MASK) == 0 && (ocp_data & BD_MASK)) {
1182 netif_dbg(tp, probe, tp->netdev, 1183 netif_dbg(tp, probe, tp->netdev,
1183 "Invalid variant for MAC pass through\n"); 1184 "Invalid variant for MAC pass through\n");
1184 return -ENODEV; 1185 return -ENODEV;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 5209ee9aac47..2aae11feff0c 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2219,7 +2219,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
2219 struct pcpu_sw_netstats *tx_stats, *rx_stats; 2219 struct pcpu_sw_netstats *tx_stats, *rx_stats;
2220 union vxlan_addr loopback; 2220 union vxlan_addr loopback;
2221 union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip; 2221 union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;
2222 struct net_device *dev = skb->dev; 2222 struct net_device *dev;
2223 int len = skb->len; 2223 int len = skb->len;
2224 2224
2225 tx_stats = this_cpu_ptr(src_vxlan->dev->tstats); 2225 tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
@@ -2239,9 +2239,15 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
2239#endif 2239#endif
2240 } 2240 }
2241 2241
2242 rcu_read_lock();
2243 dev = skb->dev;
2244 if (unlikely(!(dev->flags & IFF_UP))) {
2245 kfree_skb(skb);
2246 goto drop;
2247 }
2248
2242 if (dst_vxlan->cfg.flags & VXLAN_F_LEARN) 2249 if (dst_vxlan->cfg.flags & VXLAN_F_LEARN)
2243 vxlan_snoop(skb->dev, &loopback, eth_hdr(skb)->h_source, 0, 2250 vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0, vni);
2244 vni);
2245 2251
2246 u64_stats_update_begin(&tx_stats->syncp); 2252 u64_stats_update_begin(&tx_stats->syncp);
2247 tx_stats->tx_packets++; 2253 tx_stats->tx_packets++;
@@ -2254,8 +2260,10 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
2254 rx_stats->rx_bytes += len; 2260 rx_stats->rx_bytes += len;
2255 u64_stats_update_end(&rx_stats->syncp); 2261 u64_stats_update_end(&rx_stats->syncp);
2256 } else { 2262 } else {
2263drop:
2257 dev->stats.rx_dropped++; 2264 dev->stats.rx_dropped++;
2258 } 2265 }
2266 rcu_read_unlock();
2259} 2267}
2260 2268
2261static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev, 2269static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
index 0e6b43bb4678..a5ea3ba495a4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
@@ -158,39 +158,49 @@ static const struct ieee80211_ops mt76x0u_ops = {
158 .get_txpower = mt76x02_get_txpower, 158 .get_txpower = mt76x02_get_txpower,
159}; 159};
160 160
161static int mt76x0u_register_device(struct mt76x02_dev *dev) 161static int mt76x0u_init_hardware(struct mt76x02_dev *dev)
162{ 162{
163 struct ieee80211_hw *hw = dev->mt76.hw;
164 int err; 163 int err;
165 164
166 err = mt76u_alloc_queues(&dev->mt76);
167 if (err < 0)
168 goto out_err;
169
170 err = mt76u_mcu_init_rx(&dev->mt76);
171 if (err < 0)
172 goto out_err;
173
174 mt76x0_chip_onoff(dev, true, true); 165 mt76x0_chip_onoff(dev, true, true);
175 if (!mt76x02_wait_for_mac(&dev->mt76)) { 166
176 err = -ETIMEDOUT; 167 if (!mt76x02_wait_for_mac(&dev->mt76))
177 goto out_err; 168 return -ETIMEDOUT;
178 }
179 169
180 err = mt76x0u_mcu_init(dev); 170 err = mt76x0u_mcu_init(dev);
181 if (err < 0) 171 if (err < 0)
182 goto out_err; 172 return err;
183 173
184 mt76x0_init_usb_dma(dev); 174 mt76x0_init_usb_dma(dev);
185 err = mt76x0_init_hardware(dev); 175 err = mt76x0_init_hardware(dev);
186 if (err < 0) 176 if (err < 0)
187 goto out_err; 177 return err;
188 178
189 mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e); 179 mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e);
190 mt76_wr(dev, MT_TXOP_CTRL_CFG, 180 mt76_wr(dev, MT_TXOP_CTRL_CFG,
191 FIELD_PREP(MT_TXOP_TRUN_EN, 0x3f) | 181 FIELD_PREP(MT_TXOP_TRUN_EN, 0x3f) |
192 FIELD_PREP(MT_TXOP_EXT_CCA_DLY, 0x58)); 182 FIELD_PREP(MT_TXOP_EXT_CCA_DLY, 0x58));
193 183
184 return 0;
185}
186
187static int mt76x0u_register_device(struct mt76x02_dev *dev)
188{
189 struct ieee80211_hw *hw = dev->mt76.hw;
190 int err;
191
192 err = mt76u_alloc_queues(&dev->mt76);
193 if (err < 0)
194 goto out_err;
195
196 err = mt76u_mcu_init_rx(&dev->mt76);
197 if (err < 0)
198 goto out_err;
199
200 err = mt76x0u_init_hardware(dev);
201 if (err < 0)
202 goto out_err;
203
194 err = mt76x0_register_device(dev); 204 err = mt76x0_register_device(dev);
195 if (err < 0) 205 if (err < 0)
196 goto out_err; 206 goto out_err;
@@ -301,6 +311,8 @@ static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,
301 311
302 mt76u_stop_queues(&dev->mt76); 312 mt76u_stop_queues(&dev->mt76);
303 mt76x0u_mac_stop(dev); 313 mt76x0u_mac_stop(dev);
314 clear_bit(MT76_STATE_MCU_RUNNING, &dev->mt76.state);
315 mt76x0_chip_onoff(dev, false, false);
304 usb_kill_urb(usb->mcu.res.urb); 316 usb_kill_urb(usb->mcu.res.urb);
305 317
306 return 0; 318 return 0;
@@ -328,7 +340,7 @@ static int __maybe_unused mt76x0_resume(struct usb_interface *usb_intf)
328 tasklet_enable(&usb->rx_tasklet); 340 tasklet_enable(&usb->rx_tasklet);
329 tasklet_enable(&usb->tx_tasklet); 341 tasklet_enable(&usb->tx_tasklet);
330 342
331 ret = mt76x0_init_hardware(dev); 343 ret = mt76x0u_init_hardware(dev);
332 if (ret) 344 if (ret)
333 goto err; 345 goto err;
334 346