aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/arcnet/arcnet.c2
-rw-r--r--drivers/net/can/sja1000/peak_pci.c1
-rw-r--r--drivers/net/dsa/mv88e6xxx.c3
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c20
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c4
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-dev.c2
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c8
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.c24
-rw-r--r--drivers/net/ethernet/arc/emac_arc.c1
-rw-r--r--drivers/net/ethernet/broadcom/bcm63xx_enet.c33
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c7
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c20
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c12
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c33
-rw-r--r--drivers/net/ethernet/brocade/bna/bfa_ioc.c13
-rw-r--r--drivers/net/ethernet/brocade/bna/bna_tx_rx.c2
-rw-r--r--drivers/net/ethernet/brocade/bna/bna_types.h1
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad.c29
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad.h2
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad_ethtool.c4
-rw-r--r--drivers/net/ethernet/cavium/Kconfig2
-rw-r--r--drivers/net/ethernet/cavium/thunder/nic_main.c42
-rw-r--r--drivers/net/ethernet/cavium/thunder/nic_reg.h4
-rw-r--r--drivers/net/ethernet/cavium/thunder/nicvf_main.c2
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h5
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h2
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c31
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h10
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c38
-rw-r--r--drivers/net/ethernet/freescale/fsl_pq_mdio.c34
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c23
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c4
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ptp.c1
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c8
-rw-r--r--drivers/net/ethernet/hisilicon/hip04_eth.c2
-rw-r--r--drivers/net/ethernet/ibm/emac/core.h6
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq.c13
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c6
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c6
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq.c13
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c52
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c16
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fw.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/port.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/item.h4
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/pci.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/switchx2.c2
-rw-r--r--drivers/net/ethernet/micrel/ks8851.c1
-rw-r--r--drivers/net/ethernet/moxa/moxart_ether.c1
-rw-r--r--drivers/net/ethernet/nvidia/forcedeth.c24
-rw-r--r--drivers/net/ethernet/nxp/lpc_eth.c13
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic.h1
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c18
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c111
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c14
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c11
-rw-r--r--drivers/net/ethernet/sun/sunvnet.c17
-rw-r--r--drivers/net/ethernet/ti/cpsw.c15
-rw-r--r--drivers/net/ethernet/ti/netcp_core.c74
-rw-r--r--drivers/net/ethernet/ti/netcp_ethss.c55
-rw-r--r--drivers/net/ethernet/via/Kconfig2
-rw-r--r--drivers/net/ethernet/via/via-rhine.c3
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c2
-rw-r--r--drivers/net/fjes/fjes_hw.c8
-rw-r--r--drivers/net/geneve.c84
-rw-r--r--drivers/net/irda/ali-ircc.c6
-rw-r--r--drivers/net/macvtap.c6
-rw-r--r--drivers/net/phy/Kconfig7
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/dp83848.c99
-rw-r--r--drivers/net/phy/fixed_phy.c2
-rw-r--r--drivers/net/phy/marvell.c9
-rw-r--r--drivers/net/phy/mdio-bcm-unimac.c1
-rw-r--r--drivers/net/phy/mdio-gpio.c1
-rw-r--r--drivers/net/phy/mdio-mux-mmioreg.c2
-rw-r--r--drivers/net/phy/mdio-mux.c20
-rw-r--r--drivers/net/phy/mdio_bus.c31
-rw-r--r--drivers/net/phy/micrel.c23
-rw-r--r--drivers/net/phy/phy_device.c62
-rw-r--r--drivers/net/phy/smsc.c19
-rw-r--r--drivers/net/phy/vitesse.c14
-rw-r--r--drivers/net/ppp/ppp_generic.c4
-rw-r--r--drivers/net/ppp/pppoe.c3
-rw-r--r--drivers/net/usb/Kconfig12
-rw-r--r--drivers/net/usb/Makefile2
-rw-r--r--drivers/net/usb/asix_common.c4
-rw-r--r--drivers/net/usb/asix_devices.c4
-rw-r--r--drivers/net/usb/ch9200.c432
-rw-r--r--drivers/net/usb/qmi_wwan.c4
-rw-r--r--drivers/net/vrf.c3
-rw-r--r--drivers/net/vxlan.c63
-rw-r--r--drivers/net/wireless/ath/ath10k/hw.h4
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c1
-rw-r--r--drivers/net/wireless/b43/main.c1
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/lib.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-7000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/d3.c27
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw.c4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mvm.h5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/ops.c1
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c1
-rw-r--r--drivers/net/wireless/rtlwifi/pci.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8821ae/hw.c17
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8821ae/sw.c5
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h3
-rw-r--r--drivers/net/xen-netback/xenbus.c6
-rw-r--r--drivers/net/xen-netfront.c14
122 files changed, 1540 insertions, 491 deletions
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 10f71c732b59..816d0e94961c 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -326,7 +326,7 @@ static void arcdev_setup(struct net_device *dev)
326 dev->type = ARPHRD_ARCNET; 326 dev->type = ARPHRD_ARCNET;
327 dev->netdev_ops = &arcnet_netdev_ops; 327 dev->netdev_ops = &arcnet_netdev_ops;
328 dev->header_ops = &arcnet_header_ops; 328 dev->header_ops = &arcnet_header_ops;
329 dev->hard_header_len = sizeof(struct archdr); 329 dev->hard_header_len = sizeof(struct arc_hardware);
330 dev->mtu = choose_mtu(); 330 dev->mtu = choose_mtu();
331 331
332 dev->addr_len = ARCNET_ALEN; 332 dev->addr_len = ARCNET_ALEN;
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index e5fac368068a..131026fbc2d7 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -87,6 +87,7 @@ static const struct pci_device_id peak_pci_tbl[] = {
87 {PEAK_PCI_VENDOR_ID, PEAK_PC_104P_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 87 {PEAK_PCI_VENDOR_ID, PEAK_PC_104P_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
88 {PEAK_PCI_VENDOR_ID, PEAK_PCI_104E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 88 {PEAK_PCI_VENDOR_ID, PEAK_PCI_104E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
89 {PEAK_PCI_VENDOR_ID, PEAK_CPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 89 {PEAK_PCI_VENDOR_ID, PEAK_CPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
90 {PEAK_PCI_VENDOR_ID, PEAK_PCIE_OEM_ID, PCI_ANY_ID, PCI_ANY_ID,},
90#ifdef CONFIG_CAN_PEAK_PCIEC 91#ifdef CONFIG_CAN_PEAK_PCIEC
91 {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 92 {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
92 {PEAK_PCI_VENDOR_ID, PEAK_PCIEC34_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 93 {PEAK_PCI_VENDOR_ID, PEAK_PCIEC34_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 6f13f7206762..1f7dd927cc5e 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2000,6 +2000,7 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
2000 */ 2000 */
2001 reg = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_PCS_CTRL); 2001 reg = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_PCS_CTRL);
2002 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { 2002 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) {
2003 reg &= ~PORT_PCS_CTRL_UNFORCED;
2003 reg |= PORT_PCS_CTRL_FORCE_LINK | 2004 reg |= PORT_PCS_CTRL_FORCE_LINK |
2004 PORT_PCS_CTRL_LINK_UP | 2005 PORT_PCS_CTRL_LINK_UP |
2005 PORT_PCS_CTRL_DUPLEX_FULL | 2006 PORT_PCS_CTRL_DUPLEX_FULL |
@@ -2050,6 +2051,8 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
2050 reg |= PORT_CONTROL_FRAME_ETHER_TYPE_DSA; 2051 reg |= PORT_CONTROL_FRAME_ETHER_TYPE_DSA;
2051 else 2052 else
2052 reg |= PORT_CONTROL_FRAME_MODE_DSA; 2053 reg |= PORT_CONTROL_FRAME_MODE_DSA;
2054 reg |= PORT_CONTROL_FORWARD_UNKNOWN |
2055 PORT_CONTROL_FORWARD_UNKNOWN_MC;
2053 } 2056 }
2054 2057
2055 if (mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds) || 2058 if (mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds) ||
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 48ce83e443c2..8d50314ac3eb 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -847,21 +847,25 @@ static int emac_probe(struct platform_device *pdev)
847 if (ndev->irq == -ENXIO) { 847 if (ndev->irq == -ENXIO) {
848 netdev_err(ndev, "No irq resource\n"); 848 netdev_err(ndev, "No irq resource\n");
849 ret = ndev->irq; 849 ret = ndev->irq;
850 goto out; 850 goto out_iounmap;
851 } 851 }
852 852
853 db->clk = devm_clk_get(&pdev->dev, NULL); 853 db->clk = devm_clk_get(&pdev->dev, NULL);
854 if (IS_ERR(db->clk)) { 854 if (IS_ERR(db->clk)) {
855 ret = PTR_ERR(db->clk); 855 ret = PTR_ERR(db->clk);
856 goto out; 856 goto out_iounmap;
857 } 857 }
858 858
859 clk_prepare_enable(db->clk); 859 ret = clk_prepare_enable(db->clk);
860 if (ret) {
861 dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
862 goto out_iounmap;
863 }
860 864
861 ret = sunxi_sram_claim(&pdev->dev); 865 ret = sunxi_sram_claim(&pdev->dev);
862 if (ret) { 866 if (ret) {
863 dev_err(&pdev->dev, "Error couldn't map SRAM to device\n"); 867 dev_err(&pdev->dev, "Error couldn't map SRAM to device\n");
864 goto out; 868 goto out_clk_disable_unprepare;
865 } 869 }
866 870
867 db->phy_node = of_parse_phandle(np, "phy", 0); 871 db->phy_node = of_parse_phandle(np, "phy", 0);
@@ -910,6 +914,10 @@ static int emac_probe(struct platform_device *pdev)
910 914
911out_release_sram: 915out_release_sram:
912 sunxi_sram_release(&pdev->dev); 916 sunxi_sram_release(&pdev->dev);
917out_clk_disable_unprepare:
918 clk_disable_unprepare(db->clk);
919out_iounmap:
920 iounmap(db->membase);
913out: 921out:
914 dev_err(db->dev, "not found (%d).\n", ret); 922 dev_err(db->dev, "not found (%d).\n", ret);
915 923
@@ -921,8 +929,12 @@ out:
921static int emac_remove(struct platform_device *pdev) 929static int emac_remove(struct platform_device *pdev)
922{ 930{
923 struct net_device *ndev = platform_get_drvdata(pdev); 931 struct net_device *ndev = platform_get_drvdata(pdev);
932 struct emac_board_info *db = netdev_priv(ndev);
924 933
925 unregister_netdev(ndev); 934 unregister_netdev(ndev);
935 sunxi_sram_release(&pdev->dev);
936 clk_disable_unprepare(db->clk);
937 iounmap(db->membase);
926 free_netdev(ndev); 938 free_netdev(ndev);
927 939
928 dev_dbg(&pdev->dev, "released and freed device\n"); 940 dev_dbg(&pdev->dev, "released and freed device\n");
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
index 2c063b60db4b..96f485ab612e 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
@@ -327,9 +327,13 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
327 pdata->debugfs_xpcs_reg = 0; 327 pdata->debugfs_xpcs_reg = 0;
328 328
329 buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name); 329 buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name);
330 if (!buf)
331 return;
332
330 pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL); 333 pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL);
331 if (!pdata->xgbe_debugfs) { 334 if (!pdata->xgbe_debugfs) {
332 netdev_err(pdata->netdev, "debugfs_create_dir failed\n"); 335 netdev_err(pdata->netdev, "debugfs_create_dir failed\n");
336 kfree(buf);
333 return; 337 return;
334 } 338 }
335 339
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index a4473d8ff4fa..f672dba345f7 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -1595,7 +1595,7 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
1595 packet->rdesc_count, 1); 1595 packet->rdesc_count, 1);
1596 1596
1597 /* Make sure ownership is written to the descriptor */ 1597 /* Make sure ownership is written to the descriptor */
1598 dma_wmb(); 1598 smp_wmb();
1599 1599
1600 ring->cur = cur_index + 1; 1600 ring->cur = cur_index + 1;
1601 if (!packet->skb->xmit_more || 1601 if (!packet->skb->xmit_more ||
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index aae9d5ecd182..dde0486667e0 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1807,6 +1807,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
1807 struct netdev_queue *txq; 1807 struct netdev_queue *txq;
1808 int processed = 0; 1808 int processed = 0;
1809 unsigned int tx_packets = 0, tx_bytes = 0; 1809 unsigned int tx_packets = 0, tx_bytes = 0;
1810 unsigned int cur;
1810 1811
1811 DBGPR("-->xgbe_tx_poll\n"); 1812 DBGPR("-->xgbe_tx_poll\n");
1812 1813
@@ -1814,10 +1815,15 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
1814 if (!ring) 1815 if (!ring)
1815 return 0; 1816 return 0;
1816 1817
1818 cur = ring->cur;
1819
1820 /* Be sure we get ring->cur before accessing descriptor data */
1821 smp_rmb();
1822
1817 txq = netdev_get_tx_queue(netdev, channel->queue_index); 1823 txq = netdev_get_tx_queue(netdev, channel->queue_index);
1818 1824
1819 while ((processed < XGBE_TX_DESC_MAX_PROC) && 1825 while ((processed < XGBE_TX_DESC_MAX_PROC) &&
1820 (ring->dirty != ring->cur)) { 1826 (ring->dirty != cur)) {
1821 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); 1827 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty);
1822 rdesc = rdata->rdesc; 1828 rdesc = rdata->rdesc;
1823 1829
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index cfa37041ab71..c4bb8027b3fb 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -689,16 +689,24 @@ static int xgene_enet_phy_connect(struct net_device *ndev)
689 netdev_dbg(ndev, "No phy-handle found in DT\n"); 689 netdev_dbg(ndev, "No phy-handle found in DT\n");
690 return -ENODEV; 690 return -ENODEV;
691 } 691 }
692 pdata->phy_dev = of_phy_find_device(phy_np);
693 }
694 692
695 phy_dev = pdata->phy_dev; 693 phy_dev = of_phy_connect(ndev, phy_np, &xgene_enet_adjust_link,
694 0, pdata->phy_mode);
695 if (!phy_dev) {
696 netdev_err(ndev, "Could not connect to PHY\n");
697 return -ENODEV;
698 }
699
700 pdata->phy_dev = phy_dev;
701 } else {
702 phy_dev = pdata->phy_dev;
696 703
697 if (!phy_dev || 704 if (!phy_dev ||
698 phy_connect_direct(ndev, phy_dev, &xgene_enet_adjust_link, 705 phy_connect_direct(ndev, phy_dev, &xgene_enet_adjust_link,
699 pdata->phy_mode)) { 706 pdata->phy_mode)) {
700 netdev_err(ndev, "Could not connect to PHY\n"); 707 netdev_err(ndev, "Could not connect to PHY\n");
701 return -ENODEV; 708 return -ENODEV;
709 }
702 } 710 }
703 711
704 pdata->phy_speed = SPEED_UNKNOWN; 712 pdata->phy_speed = SPEED_UNKNOWN;
diff --git a/drivers/net/ethernet/arc/emac_arc.c b/drivers/net/ethernet/arc/emac_arc.c
index f9cb99bfb511..ffd180570920 100644
--- a/drivers/net/ethernet/arc/emac_arc.c
+++ b/drivers/net/ethernet/arc/emac_arc.c
@@ -78,6 +78,7 @@ static const struct of_device_id emac_arc_dt_ids[] = {
78 { .compatible = "snps,arc-emac" }, 78 { .compatible = "snps,arc-emac" },
79 { /* Sentinel */ } 79 { /* Sentinel */ }
80}; 80};
81MODULE_DEVICE_TABLE(of, emac_arc_dt_ids);
81 82
82static struct platform_driver emac_arc_driver = { 83static struct platform_driver emac_arc_driver = {
83 .probe = emac_arc_probe, 84 .probe = emac_arc_probe,
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index a7f2cc3e485e..4183c2abeeeb 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -2049,7 +2049,7 @@ static void swphy_poll_timer(unsigned long data)
2049 2049
2050 for (i = 0; i < priv->num_ports; i++) { 2050 for (i = 0; i < priv->num_ports; i++) {
2051 struct bcm63xx_enetsw_port *port; 2051 struct bcm63xx_enetsw_port *port;
2052 int val, j, up, advertise, lpa, lpa2, speed, duplex, media; 2052 int val, j, up, advertise, lpa, speed, duplex, media;
2053 int external_phy = bcm_enet_port_is_rgmii(i); 2053 int external_phy = bcm_enet_port_is_rgmii(i);
2054 u8 override; 2054 u8 override;
2055 2055
@@ -2092,22 +2092,27 @@ static void swphy_poll_timer(unsigned long data)
2092 lpa = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id, 2092 lpa = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id,
2093 MII_LPA); 2093 MII_LPA);
2094 2094
2095 lpa2 = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id,
2096 MII_STAT1000);
2097
2098 /* figure out media and duplex from advertise and LPA values */ 2095 /* figure out media and duplex from advertise and LPA values */
2099 media = mii_nway_result(lpa & advertise); 2096 media = mii_nway_result(lpa & advertise);
2100 duplex = (media & ADVERTISE_FULL) ? 1 : 0; 2097 duplex = (media & ADVERTISE_FULL) ? 1 : 0;
2101 if (lpa2 & LPA_1000FULL) 2098
2102 duplex = 1; 2099 if (media & (ADVERTISE_100FULL | ADVERTISE_100HALF))
2103 2100 speed = 100;
2104 if (lpa2 & (LPA_1000FULL | LPA_1000HALF)) 2101 else
2105 speed = 1000; 2102 speed = 10;
2106 else { 2103
2107 if (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)) 2104 if (val & BMSR_ESTATEN) {
2108 speed = 100; 2105 advertise = bcmenet_sw_mdio_read(priv, external_phy,
2109 else 2106 port->phy_id, MII_CTRL1000);
2110 speed = 10; 2107
2108 lpa = bcmenet_sw_mdio_read(priv, external_phy,
2109 port->phy_id, MII_STAT1000);
2110
2111 if (advertise & (ADVERTISE_1000FULL | ADVERTISE_1000HALF)
2112 && lpa & (LPA_1000FULL | LPA_1000HALF)) {
2113 speed = 1000;
2114 duplex = (lpa & LPA_1000FULL);
2115 }
2111 } 2116 }
2112 2117
2113 dev_info(&priv->pdev->dev, 2118 dev_info(&priv->pdev->dev,
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index b9a5a97ed4dd..f1b5364f3521 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2079,6 +2079,7 @@ static const struct of_device_id bcm_sysport_of_match[] = {
2079 { .compatible = "brcm,systemport" }, 2079 { .compatible = "brcm,systemport" },
2080 { /* sentinel */ } 2080 { /* sentinel */ }
2081}; 2081};
2082MODULE_DEVICE_TABLE(of, bcm_sysport_of_match);
2082 2083
2083static struct platform_driver bcm_sysport_driver = { 2084static struct platform_driver bcm_sysport_driver = {
2084 .probe = bcm_sysport_probe, 2085 .probe = bcm_sysport_probe,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index ba936635322a..b5e64b02200c 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1946,6 +1946,7 @@ struct bnx2x {
1946 u16 vlan_cnt; 1946 u16 vlan_cnt;
1947 u16 vlan_credit; 1947 u16 vlan_credit;
1948 u16 vxlan_dst_port; 1948 u16 vxlan_dst_port;
1949 u8 vxlan_dst_port_count;
1949 bool accept_any_vlan; 1950 bool accept_any_vlan;
1950}; 1951};
1951 1952
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index aeb7ce64452e..be628bd9fb18 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -3351,6 +3351,13 @@ static int bnx2x_set_rss_flags(struct bnx2x *bp, struct ethtool_rxnfc *info)
3351 udp_rss_requested = 0; 3351 udp_rss_requested = 0;
3352 else 3352 else
3353 return -EINVAL; 3353 return -EINVAL;
3354
3355 if (CHIP_IS_E1x(bp) && udp_rss_requested) {
3356 DP(BNX2X_MSG_ETHTOOL,
3357 "57710, 57711 boards don't support RSS according to UDP 4-tuple\n");
3358 return -EINVAL;
3359 }
3360
3354 if ((info->flow_type == UDP_V4_FLOW) && 3361 if ((info->flow_type == UDP_V4_FLOW) &&
3355 (bp->rss_conf_obj.udp_rss_v4 != udp_rss_requested)) { 3362 (bp->rss_conf_obj.udp_rss_v4 != udp_rss_requested)) {
3356 bp->rss_conf_obj.udp_rss_v4 = udp_rss_requested; 3363 bp->rss_conf_obj.udp_rss_v4 = udp_rss_requested;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index e3da2bddf143..f1d62d5dbaff 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -3705,16 +3705,14 @@ out:
3705 3705
3706void bnx2x_update_mfw_dump(struct bnx2x *bp) 3706void bnx2x_update_mfw_dump(struct bnx2x *bp)
3707{ 3707{
3708 struct timeval epoc;
3709 u32 drv_ver; 3708 u32 drv_ver;
3710 u32 valid_dump; 3709 u32 valid_dump;
3711 3710
3712 if (!SHMEM2_HAS(bp, drv_info)) 3711 if (!SHMEM2_HAS(bp, drv_info))
3713 return; 3712 return;
3714 3713
3715 /* Update Driver load time */ 3714 /* Update Driver load time, possibly broken in y2038 */
3716 do_gettimeofday(&epoc); 3715 SHMEM2_WR(bp, drv_info.epoc, (u32)ktime_get_real_seconds());
3717 SHMEM2_WR(bp, drv_info.epoc, epoc.tv_sec);
3718 3716
3719 drv_ver = bnx2x_update_mng_version_utility(DRV_MODULE_VERSION, true); 3717 drv_ver = bnx2x_update_mng_version_utility(DRV_MODULE_VERSION, true);
3720 SHMEM2_WR(bp, drv_info.drv_ver, drv_ver); 3718 SHMEM2_WR(bp, drv_info.drv_ver, drv_ver);
@@ -10110,12 +10108,18 @@ static void __bnx2x_add_vxlan_port(struct bnx2x *bp, u16 port)
10110 if (!netif_running(bp->dev)) 10108 if (!netif_running(bp->dev))
10111 return; 10109 return;
10112 10110
10113 if (bp->vxlan_dst_port || !IS_PF(bp)) { 10111 if (bp->vxlan_dst_port_count && bp->vxlan_dst_port == port) {
10112 bp->vxlan_dst_port_count++;
10113 return;
10114 }
10115
10116 if (bp->vxlan_dst_port_count || !IS_PF(bp)) {
10114 DP(BNX2X_MSG_SP, "Vxlan destination port limit reached\n"); 10117 DP(BNX2X_MSG_SP, "Vxlan destination port limit reached\n");
10115 return; 10118 return;
10116 } 10119 }
10117 10120
10118 bp->vxlan_dst_port = port; 10121 bp->vxlan_dst_port = port;
10122 bp->vxlan_dst_port_count = 1;
10119 bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_ADD_VXLAN_PORT, 0); 10123 bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_ADD_VXLAN_PORT, 0);
10120} 10124}
10121 10125
@@ -10130,10 +10134,14 @@ static void bnx2x_add_vxlan_port(struct net_device *netdev,
10130 10134
10131static void __bnx2x_del_vxlan_port(struct bnx2x *bp, u16 port) 10135static void __bnx2x_del_vxlan_port(struct bnx2x *bp, u16 port)
10132{ 10136{
10133 if (!bp->vxlan_dst_port || bp->vxlan_dst_port != port || !IS_PF(bp)) { 10137 if (!bp->vxlan_dst_port_count || bp->vxlan_dst_port != port ||
10138 !IS_PF(bp)) {
10134 DP(BNX2X_MSG_SP, "Invalid vxlan port\n"); 10139 DP(BNX2X_MSG_SP, "Invalid vxlan port\n");
10135 return; 10140 return;
10136 } 10141 }
10142 bp->vxlan_dst_port--;
10143 if (bp->vxlan_dst_port)
10144 return;
10137 10145
10138 if (netif_running(bp->dev)) { 10146 if (netif_running(bp->dev)) {
10139 bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_DEL_VXLAN_PORT, 0); 10147 bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_DEL_VXLAN_PORT, 0);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index c9bd7f16018e..ff702a707a91 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -4319,8 +4319,16 @@ static int bnx2x_setup_rss(struct bnx2x *bp,
4319 4319
4320 /* RSS keys */ 4320 /* RSS keys */
4321 if (test_bit(BNX2X_RSS_SET_SRCH, &p->rss_flags)) { 4321 if (test_bit(BNX2X_RSS_SET_SRCH, &p->rss_flags)) {
4322 memcpy(&data->rss_key[0], &p->rss_key[0], 4322 u8 *dst = (u8 *)(data->rss_key) + sizeof(data->rss_key);
4323 sizeof(data->rss_key)); 4323 const u8 *src = (const u8 *)p->rss_key;
4324 int i;
4325
4326 /* Apparently, bnx2x reads this array in reverse order
4327 * We need to byte swap rss_key to comply with Toeplitz specs.
4328 */
4329 for (i = 0; i < sizeof(data->rss_key); i++)
4330 *--dst = *src++;
4331
4324 caps |= ETH_RSS_UPDATE_RAMROD_DATA_UPDATE_RSS_KEY; 4332 caps |= ETH_RSS_UPDATE_RAMROD_DATA_UPDATE_RSS_KEY;
4325 } 4333 }
4326 4334
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index fadbd0088d3e..1805541b4240 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1683,6 +1683,24 @@ static void bcmgenet_intr_disable(struct bcmgenet_priv *priv)
1683 bcmgenet_intrl2_1_writel(priv, 0, INTRL2_CPU_MASK_CLEAR); 1683 bcmgenet_intrl2_1_writel(priv, 0, INTRL2_CPU_MASK_CLEAR);
1684} 1684}
1685 1685
1686static void bcmgenet_link_intr_enable(struct bcmgenet_priv *priv)
1687{
1688 u32 int0_enable = 0;
1689
1690 /* Monitor cable plug/unplugged event for internal PHY, external PHY
1691 * and MoCA PHY
1692 */
1693 if (priv->internal_phy) {
1694 int0_enable |= UMAC_IRQ_LINK_EVENT;
1695 } else if (priv->ext_phy) {
1696 int0_enable |= UMAC_IRQ_LINK_EVENT;
1697 } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
1698 if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET)
1699 int0_enable |= UMAC_IRQ_LINK_EVENT;
1700 }
1701 bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR);
1702}
1703
1686static int init_umac(struct bcmgenet_priv *priv) 1704static int init_umac(struct bcmgenet_priv *priv)
1687{ 1705{
1688 struct device *kdev = &priv->pdev->dev; 1706 struct device *kdev = &priv->pdev->dev;
@@ -1723,15 +1741,8 @@ static int init_umac(struct bcmgenet_priv *priv)
1723 /* Enable Tx default queue 16 interrupts */ 1741 /* Enable Tx default queue 16 interrupts */
1724 int0_enable |= UMAC_IRQ_TXDMA_DONE; 1742 int0_enable |= UMAC_IRQ_TXDMA_DONE;
1725 1743
1726 /* Monitor cable plug/unplugged event for internal PHY */ 1744 /* Configure backpressure vectors for MoCA */
1727 if (priv->internal_phy) { 1745 if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
1728 int0_enable |= UMAC_IRQ_LINK_EVENT;
1729 } else if (priv->ext_phy) {
1730 int0_enable |= UMAC_IRQ_LINK_EVENT;
1731 } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
1732 if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET)
1733 int0_enable |= UMAC_IRQ_LINK_EVENT;
1734
1735 reg = bcmgenet_bp_mc_get(priv); 1746 reg = bcmgenet_bp_mc_get(priv);
1736 reg |= BIT(priv->hw_params->bp_in_en_shift); 1747 reg |= BIT(priv->hw_params->bp_in_en_shift);
1737 1748
@@ -2645,6 +2656,9 @@ static void bcmgenet_netif_start(struct net_device *dev)
2645 2656
2646 netif_tx_start_all_queues(dev); 2657 netif_tx_start_all_queues(dev);
2647 2658
2659 /* Monitor link interrupts now */
2660 bcmgenet_link_intr_enable(priv);
2661
2648 phy_start(priv->phydev); 2662 phy_start(priv->phydev);
2649} 2663}
2650 2664
@@ -3155,6 +3169,7 @@ static const struct of_device_id bcmgenet_match[] = {
3155 { .compatible = "brcm,genet-v4", .data = (void *)GENET_V4 }, 3169 { .compatible = "brcm,genet-v4", .data = (void *)GENET_V4 },
3156 { }, 3170 { },
3157}; 3171};
3172MODULE_DEVICE_TABLE(of, bcmgenet_match);
3158 3173
3159static int bcmgenet_probe(struct platform_device *pdev) 3174static int bcmgenet_probe(struct platform_device *pdev)
3160{ 3175{
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index b7a0f7879de2..9e59663a6ead 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -1543,7 +1543,7 @@ bfa_flash_cmd_act_check(void __iomem *pci_bar)
1543} 1543}
1544 1544
1545/* Flush FLI data fifo. */ 1545/* Flush FLI data fifo. */
1546static u32 1546static int
1547bfa_flash_fifo_flush(void __iomem *pci_bar) 1547bfa_flash_fifo_flush(void __iomem *pci_bar)
1548{ 1548{
1549 u32 i; 1549 u32 i;
@@ -1573,11 +1573,11 @@ bfa_flash_fifo_flush(void __iomem *pci_bar)
1573} 1573}
1574 1574
1575/* Read flash status. */ 1575/* Read flash status. */
1576static u32 1576static int
1577bfa_flash_status_read(void __iomem *pci_bar) 1577bfa_flash_status_read(void __iomem *pci_bar)
1578{ 1578{
1579 union bfa_flash_dev_status_reg dev_status; 1579 union bfa_flash_dev_status_reg dev_status;
1580 u32 status; 1580 int status;
1581 u32 ret_status; 1581 u32 ret_status;
1582 int i; 1582 int i;
1583 1583
@@ -1611,11 +1611,11 @@ bfa_flash_status_read(void __iomem *pci_bar)
1611} 1611}
1612 1612
1613/* Start flash read operation. */ 1613/* Start flash read operation. */
1614static u32 1614static int
1615bfa_flash_read_start(void __iomem *pci_bar, u32 offset, u32 len, 1615bfa_flash_read_start(void __iomem *pci_bar, u32 offset, u32 len,
1616 char *buf) 1616 char *buf)
1617{ 1617{
1618 u32 status; 1618 int status;
1619 1619
1620 /* len must be mutiple of 4 and not exceeding fifo size */ 1620 /* len must be mutiple of 4 and not exceeding fifo size */
1621 if (len == 0 || len > BFA_FLASH_FIFO_SIZE || (len & 0x03) != 0) 1621 if (len == 0 || len > BFA_FLASH_FIFO_SIZE || (len & 0x03) != 0)
@@ -1703,7 +1703,8 @@ static enum bfa_status
1703bfa_flash_raw_read(void __iomem *pci_bar, u32 offset, char *buf, 1703bfa_flash_raw_read(void __iomem *pci_bar, u32 offset, char *buf,
1704 u32 len) 1704 u32 len)
1705{ 1705{
1706 u32 n, status; 1706 u32 n;
1707 int status;
1707 u32 off, l, s, residue, fifo_sz; 1708 u32 off, l, s, residue, fifo_sz;
1708 1709
1709 residue = len; 1710 residue = len;
diff --git a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
index 5d0753cc7e73..04b0d16b210e 100644
--- a/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
+++ b/drivers/net/ethernet/brocade/bna/bna_tx_rx.c
@@ -2400,6 +2400,7 @@ bna_rx_create(struct bna *bna, struct bnad *bnad,
2400 q0->rcb->id = 0; 2400 q0->rcb->id = 0;
2401 q0->rx_packets = q0->rx_bytes = 0; 2401 q0->rx_packets = q0->rx_bytes = 0;
2402 q0->rx_packets_with_error = q0->rxbuf_alloc_failed = 0; 2402 q0->rx_packets_with_error = q0->rxbuf_alloc_failed = 0;
2403 q0->rxbuf_map_failed = 0;
2403 2404
2404 bna_rxq_qpt_setup(q0, rxp, dpage_count, PAGE_SIZE, 2405 bna_rxq_qpt_setup(q0, rxp, dpage_count, PAGE_SIZE,
2405 &dqpt_mem[i], &dsqpt_mem[i], &dpage_mem[i]); 2406 &dqpt_mem[i], &dsqpt_mem[i], &dpage_mem[i]);
@@ -2428,6 +2429,7 @@ bna_rx_create(struct bna *bna, struct bnad *bnad,
2428 : rx_cfg->q1_buf_size; 2429 : rx_cfg->q1_buf_size;
2429 q1->rx_packets = q1->rx_bytes = 0; 2430 q1->rx_packets = q1->rx_bytes = 0;
2430 q1->rx_packets_with_error = q1->rxbuf_alloc_failed = 0; 2431 q1->rx_packets_with_error = q1->rxbuf_alloc_failed = 0;
2432 q1->rxbuf_map_failed = 0;
2431 2433
2432 bna_rxq_qpt_setup(q1, rxp, hpage_count, PAGE_SIZE, 2434 bna_rxq_qpt_setup(q1, rxp, hpage_count, PAGE_SIZE,
2433 &hqpt_mem[i], &hsqpt_mem[i], 2435 &hqpt_mem[i], &hsqpt_mem[i],
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h b/drivers/net/ethernet/brocade/bna/bna_types.h
index e0e797f2ea14..c438d032e8bf 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -587,6 +587,7 @@ struct bna_rxq {
587 u64 rx_bytes; 587 u64 rx_bytes;
588 u64 rx_packets_with_error; 588 u64 rx_packets_with_error;
589 u64 rxbuf_alloc_failed; 589 u64 rxbuf_alloc_failed;
590 u64 rxbuf_map_failed;
590}; 591};
591 592
592/* RxQ pair */ 593/* RxQ pair */
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index 506047c38607..21a0cfc3e7ec 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -399,7 +399,13 @@ bnad_rxq_refill_page(struct bnad *bnad, struct bna_rcb *rcb, u32 nalloc)
399 } 399 }
400 400
401 dma_addr = dma_map_page(&bnad->pcidev->dev, page, page_offset, 401 dma_addr = dma_map_page(&bnad->pcidev->dev, page, page_offset,
402 unmap_q->map_size, DMA_FROM_DEVICE); 402 unmap_q->map_size, DMA_FROM_DEVICE);
403 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) {
404 put_page(page);
405 BNAD_UPDATE_CTR(bnad, rxbuf_map_failed);
406 rcb->rxq->rxbuf_map_failed++;
407 goto finishing;
408 }
403 409
404 unmap->page = page; 410 unmap->page = page;
405 unmap->page_offset = page_offset; 411 unmap->page_offset = page_offset;
@@ -454,8 +460,15 @@ bnad_rxq_refill_skb(struct bnad *bnad, struct bna_rcb *rcb, u32 nalloc)
454 rcb->rxq->rxbuf_alloc_failed++; 460 rcb->rxq->rxbuf_alloc_failed++;
455 goto finishing; 461 goto finishing;
456 } 462 }
463
457 dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data, 464 dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data,
458 buff_sz, DMA_FROM_DEVICE); 465 buff_sz, DMA_FROM_DEVICE);
466 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) {
467 dev_kfree_skb_any(skb);
468 BNAD_UPDATE_CTR(bnad, rxbuf_map_failed);
469 rcb->rxq->rxbuf_map_failed++;
470 goto finishing;
471 }
459 472
460 unmap->skb = skb; 473 unmap->skb = skb;
461 dma_unmap_addr_set(&unmap->vector, dma_addr, dma_addr); 474 dma_unmap_addr_set(&unmap->vector, dma_addr, dma_addr);
@@ -3025,6 +3038,11 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
3025 unmap = head_unmap; 3038 unmap = head_unmap;
3026 dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data, 3039 dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data,
3027 len, DMA_TO_DEVICE); 3040 len, DMA_TO_DEVICE);
3041 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) {
3042 dev_kfree_skb_any(skb);
3043 BNAD_UPDATE_CTR(bnad, tx_skb_map_failed);
3044 return NETDEV_TX_OK;
3045 }
3028 BNA_SET_DMA_ADDR(dma_addr, &txqent->vector[0].host_addr); 3046 BNA_SET_DMA_ADDR(dma_addr, &txqent->vector[0].host_addr);
3029 txqent->vector[0].length = htons(len); 3047 txqent->vector[0].length = htons(len);
3030 dma_unmap_addr_set(&unmap->vectors[0], dma_addr, dma_addr); 3048 dma_unmap_addr_set(&unmap->vectors[0], dma_addr, dma_addr);
@@ -3056,6 +3074,15 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
3056 3074
3057 dma_addr = skb_frag_dma_map(&bnad->pcidev->dev, frag, 3075 dma_addr = skb_frag_dma_map(&bnad->pcidev->dev, frag,
3058 0, size, DMA_TO_DEVICE); 3076 0, size, DMA_TO_DEVICE);
3077 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) {
3078 /* Undo the changes starting at tcb->producer_index */
3079 bnad_tx_buff_unmap(bnad, unmap_q, q_depth,
3080 tcb->producer_index);
3081 dev_kfree_skb_any(skb);
3082 BNAD_UPDATE_CTR(bnad, tx_skb_map_failed);
3083 return NETDEV_TX_OK;
3084 }
3085
3059 dma_unmap_len_set(&unmap->vectors[vect_id], dma_len, size); 3086 dma_unmap_len_set(&unmap->vectors[vect_id], dma_len, size);
3060 BNA_SET_DMA_ADDR(dma_addr, &txqent->vector[vect_id].host_addr); 3087 BNA_SET_DMA_ADDR(dma_addr, &txqent->vector[vect_id].host_addr);
3061 txqent->vector[vect_id].length = htons(size); 3088 txqent->vector[vect_id].length = htons(size);
diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h
index faedbf24777e..f4ed816b93ee 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.h
+++ b/drivers/net/ethernet/brocade/bna/bnad.h
@@ -175,6 +175,7 @@ struct bnad_drv_stats {
175 u64 tx_skb_headlen_zero; 175 u64 tx_skb_headlen_zero;
176 u64 tx_skb_frag_zero; 176 u64 tx_skb_frag_zero;
177 u64 tx_skb_len_mismatch; 177 u64 tx_skb_len_mismatch;
178 u64 tx_skb_map_failed;
178 179
179 u64 hw_stats_updates; 180 u64 hw_stats_updates;
180 u64 netif_rx_dropped; 181 u64 netif_rx_dropped;
@@ -189,6 +190,7 @@ struct bnad_drv_stats {
189 u64 rx_unmap_q_alloc_failed; 190 u64 rx_unmap_q_alloc_failed;
190 191
191 u64 rxbuf_alloc_failed; 192 u64 rxbuf_alloc_failed;
193 u64 rxbuf_map_failed;
192}; 194};
193 195
194/* Complete driver stats */ 196/* Complete driver stats */
diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
index 2bdfc5dff4b1..0e4fdc3dd729 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
@@ -90,6 +90,7 @@ static const char *bnad_net_stats_strings[BNAD_ETHTOOL_STATS_NUM] = {
90 "tx_skb_headlen_zero", 90 "tx_skb_headlen_zero",
91 "tx_skb_frag_zero", 91 "tx_skb_frag_zero",
92 "tx_skb_len_mismatch", 92 "tx_skb_len_mismatch",
93 "tx_skb_map_failed",
93 "hw_stats_updates", 94 "hw_stats_updates",
94 "netif_rx_dropped", 95 "netif_rx_dropped",
95 96
@@ -102,6 +103,7 @@ static const char *bnad_net_stats_strings[BNAD_ETHTOOL_STATS_NUM] = {
102 "tx_unmap_q_alloc_failed", 103 "tx_unmap_q_alloc_failed",
103 "rx_unmap_q_alloc_failed", 104 "rx_unmap_q_alloc_failed",
104 "rxbuf_alloc_failed", 105 "rxbuf_alloc_failed",
106 "rxbuf_map_failed",
105 107
106 "mac_stats_clr_cnt", 108 "mac_stats_clr_cnt",
107 "mac_frame_64", 109 "mac_frame_64",
@@ -807,6 +809,7 @@ bnad_per_q_stats_fill(struct bnad *bnad, u64 *buf, int bi)
807 rx_packets_with_error; 809 rx_packets_with_error;
808 buf[bi++] = rcb->rxq-> 810 buf[bi++] = rcb->rxq->
809 rxbuf_alloc_failed; 811 rxbuf_alloc_failed;
812 buf[bi++] = rcb->rxq->rxbuf_map_failed;
810 buf[bi++] = rcb->producer_index; 813 buf[bi++] = rcb->producer_index;
811 buf[bi++] = rcb->consumer_index; 814 buf[bi++] = rcb->consumer_index;
812 } 815 }
@@ -821,6 +824,7 @@ bnad_per_q_stats_fill(struct bnad *bnad, u64 *buf, int bi)
821 rx_packets_with_error; 824 rx_packets_with_error;
822 buf[bi++] = rcb->rxq-> 825 buf[bi++] = rcb->rxq->
823 rxbuf_alloc_failed; 826 rxbuf_alloc_failed;
827 buf[bi++] = rcb->rxq->rxbuf_map_failed;
824 buf[bi++] = rcb->producer_index; 828 buf[bi++] = rcb->producer_index;
825 buf[bi++] = rcb->consumer_index; 829 buf[bi++] = rcb->consumer_index;
826 } 830 }
diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
index 9b35d142f47a..8fb84e69c30e 100644
--- a/drivers/net/ethernet/cavium/Kconfig
+++ b/drivers/net/ethernet/cavium/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4 4
5config NET_VENDOR_CAVIUM 5config NET_VENDOR_CAVIUM
6 tristate "Cavium ethernet drivers" 6 bool "Cavium ethernet drivers"
7 depends on PCI 7 depends on PCI
8 default y 8 default y
9 ---help--- 9 ---help---
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c
index b3a5947a2cc0..c561fdcb79a7 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
@@ -22,7 +22,6 @@
22 22
23struct nicpf { 23struct nicpf {
24 struct pci_dev *pdev; 24 struct pci_dev *pdev;
25 u8 rev_id;
26 u8 node; 25 u8 node;
27 unsigned int flags; 26 unsigned int flags;
28 u8 num_vf_en; /* No of VF enabled */ 27 u8 num_vf_en; /* No of VF enabled */
@@ -44,6 +43,7 @@ struct nicpf {
44 u8 duplex[MAX_LMAC]; 43 u8 duplex[MAX_LMAC];
45 u32 speed[MAX_LMAC]; 44 u32 speed[MAX_LMAC];
46 u16 cpi_base[MAX_NUM_VFS_SUPPORTED]; 45 u16 cpi_base[MAX_NUM_VFS_SUPPORTED];
46 u16 rssi_base[MAX_NUM_VFS_SUPPORTED];
47 u16 rss_ind_tbl_size; 47 u16 rss_ind_tbl_size;
48 bool mbx_lock[MAX_NUM_VFS_SUPPORTED]; 48 bool mbx_lock[MAX_NUM_VFS_SUPPORTED];
49 49
@@ -54,6 +54,11 @@ struct nicpf {
54 bool irq_allocated[NIC_PF_MSIX_VECTORS]; 54 bool irq_allocated[NIC_PF_MSIX_VECTORS];
55}; 55};
56 56
57static inline bool pass1_silicon(struct nicpf *nic)
58{
59 return nic->pdev->revision < 8;
60}
61
57/* Supported devices */ 62/* Supported devices */
58static const struct pci_device_id nic_id_table[] = { 63static const struct pci_device_id nic_id_table[] = {
59 { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_NIC_PF) }, 64 { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_NIC_PF) },
@@ -117,7 +122,7 @@ static void nic_send_msg_to_vf(struct nicpf *nic, int vf, union nic_mbx *mbx)
117 * when PF writes to MBOX(1), in next revisions when 122 * when PF writes to MBOX(1), in next revisions when
118 * PF writes to MBOX(0) 123 * PF writes to MBOX(0)
119 */ 124 */
120 if (nic->rev_id == 0) { 125 if (pass1_silicon(nic)) {
121 /* see the comment for nic_reg_write()/nic_reg_read() 126 /* see the comment for nic_reg_write()/nic_reg_read()
122 * functions above 127 * functions above
123 */ 128 */
@@ -305,9 +310,6 @@ static void nic_init_hw(struct nicpf *nic)
305{ 310{
306 int i; 311 int i;
307 312
308 /* Reset NIC, in case the driver is repeatedly inserted and removed */
309 nic_reg_write(nic, NIC_PF_SOFT_RESET, 1);
310
311 /* Enable NIC HW block */ 313 /* Enable NIC HW block */
312 nic_reg_write(nic, NIC_PF_CFG, 0x3); 314 nic_reg_write(nic, NIC_PF_CFG, 0x3);
313 315
@@ -395,8 +397,18 @@ static void nic_config_cpi(struct nicpf *nic, struct cpi_cfg_msg *cfg)
395 padd = cpi % 8; /* 3 bits CS out of 6bits DSCP */ 397 padd = cpi % 8; /* 3 bits CS out of 6bits DSCP */
396 398
397 /* Leave RSS_SIZE as '0' to disable RSS */ 399 /* Leave RSS_SIZE as '0' to disable RSS */
398 nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3), 400 if (pass1_silicon(nic)) {
399 (vnic << 24) | (padd << 16) | (rssi_base + rssi)); 401 nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3),
402 (vnic << 24) | (padd << 16) |
403 (rssi_base + rssi));
404 } else {
405 /* Set MPI_ALG to '0' to disable MCAM parsing */
406 nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3),
407 (padd << 16));
408 /* MPI index is same as CPI if MPI_ALG is not enabled */
409 nic_reg_write(nic, NIC_PF_MPI_0_2047_CFG | (cpi << 3),
410 (vnic << 24) | (rssi_base + rssi));
411 }
400 412
401 if ((rssi + 1) >= cfg->rq_cnt) 413 if ((rssi + 1) >= cfg->rq_cnt)
402 continue; 414 continue;
@@ -409,6 +421,7 @@ static void nic_config_cpi(struct nicpf *nic, struct cpi_cfg_msg *cfg)
409 rssi = ((cpi - cpi_base) & 0x38) >> 3; 421 rssi = ((cpi - cpi_base) & 0x38) >> 3;
410 } 422 }
411 nic->cpi_base[cfg->vf_id] = cpi_base; 423 nic->cpi_base[cfg->vf_id] = cpi_base;
424 nic->rssi_base[cfg->vf_id] = rssi_base;
412} 425}
413 426
414/* Responsds to VF with its RSS indirection table size */ 427/* Responsds to VF with its RSS indirection table size */
@@ -434,10 +447,9 @@ static void nic_config_rss(struct nicpf *nic, struct rss_cfg_msg *cfg)
434{ 447{
435 u8 qset, idx = 0; 448 u8 qset, idx = 0;
436 u64 cpi_cfg, cpi_base, rssi_base, rssi; 449 u64 cpi_cfg, cpi_base, rssi_base, rssi;
450 u64 idx_addr;
437 451
438 cpi_base = nic->cpi_base[cfg->vf_id]; 452 rssi_base = nic->rssi_base[cfg->vf_id] + cfg->tbl_offset;
439 cpi_cfg = nic_reg_read(nic, NIC_PF_CPI_0_2047_CFG | (cpi_base << 3));
440 rssi_base = (cpi_cfg & 0x0FFF) + cfg->tbl_offset;
441 453
442 rssi = rssi_base; 454 rssi = rssi_base;
443 qset = cfg->vf_id; 455 qset = cfg->vf_id;
@@ -454,9 +466,15 @@ static void nic_config_rss(struct nicpf *nic, struct rss_cfg_msg *cfg)
454 idx++; 466 idx++;
455 } 467 }
456 468
469 cpi_base = nic->cpi_base[cfg->vf_id];
470 if (pass1_silicon(nic))
471 idx_addr = NIC_PF_CPI_0_2047_CFG;
472 else
473 idx_addr = NIC_PF_MPI_0_2047_CFG;
474 cpi_cfg = nic_reg_read(nic, idx_addr | (cpi_base << 3));
457 cpi_cfg &= ~(0xFULL << 20); 475 cpi_cfg &= ~(0xFULL << 20);
458 cpi_cfg |= (cfg->hash_bits << 20); 476 cpi_cfg |= (cfg->hash_bits << 20);
459 nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi_base << 3), cpi_cfg); 477 nic_reg_write(nic, idx_addr | (cpi_base << 3), cpi_cfg);
460} 478}
461 479
462/* 4 level transmit side scheduler configutation 480/* 4 level transmit side scheduler configutation
@@ -1001,8 +1019,6 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1001 goto err_release_regions; 1019 goto err_release_regions;
1002 } 1020 }
1003 1021
1004 pci_read_config_byte(pdev, PCI_REVISION_ID, &nic->rev_id);
1005
1006 nic->node = nic_get_node_id(pdev); 1022 nic->node = nic_get_node_id(pdev);
1007 1023
1008 nic_set_lmac_vf_mapping(nic); 1024 nic_set_lmac_vf_mapping(nic);
diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h
index 58197bb2f805..dd536be20193 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_reg.h
+++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h
@@ -85,7 +85,11 @@
85#define NIC_PF_ECC3_DBE_INT_W1S (0x2708) 85#define NIC_PF_ECC3_DBE_INT_W1S (0x2708)
86#define NIC_PF_ECC3_DBE_ENA_W1C (0x2710) 86#define NIC_PF_ECC3_DBE_ENA_W1C (0x2710)
87#define NIC_PF_ECC3_DBE_ENA_W1S (0x2718) 87#define NIC_PF_ECC3_DBE_ENA_W1S (0x2718)
88#define NIC_PF_MCAM_0_191_ENA (0x100000)
89#define NIC_PF_MCAM_0_191_M_0_5_DATA (0x110000)
90#define NIC_PF_MCAM_CTRL (0x120000)
88#define NIC_PF_CPI_0_2047_CFG (0x200000) 91#define NIC_PF_CPI_0_2047_CFG (0x200000)
92#define NIC_PF_MPI_0_2047_CFG (0x210000)
89#define NIC_PF_RSSI_0_4097_RQ (0x220000) 93#define NIC_PF_RSSI_0_4097_RQ (0x220000)
90#define NIC_PF_LMAC_0_7_CFG (0x240000) 94#define NIC_PF_LMAC_0_7_CFG (0x240000)
91#define NIC_PF_LMAC_0_7_SW_XOFF (0x242000) 95#define NIC_PF_LMAC_0_7_SW_XOFF (0x242000)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index b63e579aeb12..a9377727c11c 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -29,7 +29,7 @@
29static const struct pci_device_id nicvf_id_table[] = { 29static const struct pci_device_id nicvf_id_table[] = {
30 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM, 30 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
31 PCI_DEVICE_ID_THUNDER_NIC_VF, 31 PCI_DEVICE_ID_THUNDER_NIC_VF,
32 PCI_VENDOR_ID_CAVIUM, 0xA11E) }, 32 PCI_VENDOR_ID_CAVIUM, 0xA134) },
33 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM, 33 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
34 PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF, 34 PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF,
35 PCI_VENDOR_ID_CAVIUM, 0xA11E) }, 35 PCI_VENDOR_ID_CAVIUM, 0xA11E) },
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 574c49278900..180aa9fabf48 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -977,8 +977,10 @@ static int bgx_init_of_phy(struct bgx *bgx)
977 SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); 977 SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev);
978 bgx->lmac[lmac].lmacid = lmac; 978 bgx->lmac[lmac].lmacid = lmac;
979 lmac++; 979 lmac++;
980 if (lmac == MAX_LMAC_PER_BGX) 980 if (lmac == MAX_LMAC_PER_BGX) {
981 of_node_put(np_child);
981 break; 982 break;
983 }
982 } 984 }
983 return 0; 985 return 0;
984} 986}
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index 8353a6cbfcc2..03ed00c49823 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -157,6 +157,11 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
157 CH_PCI_ID_TABLE_FENTRY(0x5090), /* Custom T540-CR */ 157 CH_PCI_ID_TABLE_FENTRY(0x5090), /* Custom T540-CR */
158 CH_PCI_ID_TABLE_FENTRY(0x5091), /* Custom T522-CR */ 158 CH_PCI_ID_TABLE_FENTRY(0x5091), /* Custom T522-CR */
159 CH_PCI_ID_TABLE_FENTRY(0x5092), /* Custom T520-CR */ 159 CH_PCI_ID_TABLE_FENTRY(0x5092), /* Custom T520-CR */
160 CH_PCI_ID_TABLE_FENTRY(0x5093), /* Custom T580-LP-CR */
161 CH_PCI_ID_TABLE_FENTRY(0x5094), /* Custom T540-CR */
162 CH_PCI_ID_TABLE_FENTRY(0x5095), /* Custom T540-CR-SO */
163 CH_PCI_ID_TABLE_FENTRY(0x5096), /* Custom T580-CR */
164 CH_PCI_ID_TABLE_FENTRY(0x5097), /* Custom T520-KR */
160 165
161 /* T6 adapters: 166 /* T6 adapters:
162 */ 167 */
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 0a27805cbbbd..d463563e1f70 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -582,6 +582,7 @@ struct be_adapter {
582 u16 pvid; 582 u16 pvid;
583 __be16 vxlan_port; 583 __be16 vxlan_port;
584 int vxlan_port_count; 584 int vxlan_port_count;
585 int vxlan_port_aliases;
585 struct phy_info phy; 586 struct phy_info phy;
586 u8 wol_cap; 587 u8 wol_cap;
587 bool wol_en; 588 bool wol_en;
@@ -591,6 +592,7 @@ struct be_adapter {
591 int be_get_temp_freq; 592 int be_get_temp_freq;
592 struct be_hwmon hwmon_info; 593 struct be_hwmon hwmon_info;
593 u8 pf_number; 594 u8 pf_number;
595 u8 pci_func_num;
594 struct rss_info rss_info; 596 struct rss_info rss_info;
595 /* Filters for packets that need to be sent to BMC */ 597 /* Filters for packets that need to be sent to BMC */
596 u32 bmc_filt_mask; 598 u32 bmc_filt_mask;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index eb323913cd39..1795c935ff02 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -851,8 +851,10 @@ static int be_cmd_notify_wait(struct be_adapter *adapter,
851 return status; 851 return status;
852 852
853 dest_wrb = be_cmd_copy(adapter, wrb); 853 dest_wrb = be_cmd_copy(adapter, wrb);
854 if (!dest_wrb) 854 if (!dest_wrb) {
855 return -EBUSY; 855 status = -EBUSY;
856 goto unlock;
857 }
856 858
857 if (use_mcc(adapter)) 859 if (use_mcc(adapter))
858 status = be_mcc_notify_wait(adapter); 860 status = be_mcc_notify_wait(adapter);
@@ -862,6 +864,7 @@ static int be_cmd_notify_wait(struct be_adapter *adapter,
862 if (!status) 864 if (!status)
863 memcpy(wrb, dest_wrb, sizeof(*wrb)); 865 memcpy(wrb, dest_wrb, sizeof(*wrb));
864 866
867unlock:
865 be_cmd_unlock(adapter); 868 be_cmd_unlock(adapter);
866 return status; 869 return status;
867} 870}
@@ -1984,6 +1987,8 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
1984 be_if_cap_flags(adapter)); 1987 be_if_cap_flags(adapter));
1985 } 1988 }
1986 flags &= be_if_cap_flags(adapter); 1989 flags &= be_if_cap_flags(adapter);
1990 if (!flags)
1991 return -ENOTSUPP;
1987 1992
1988 return __be_cmd_rx_filter(adapter, flags, value); 1993 return __be_cmd_rx_filter(adapter, flags, value);
1989} 1994}
@@ -2887,6 +2892,7 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
2887 if (!status) { 2892 if (!status) {
2888 attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr); 2893 attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
2889 adapter->hba_port_num = attribs->hba_attribs.phy_port; 2894 adapter->hba_port_num = attribs->hba_attribs.phy_port;
2895 adapter->pci_func_num = attribs->pci_func_num;
2890 serial_num = attribs->hba_attribs.controller_serial_number; 2896 serial_num = attribs->hba_attribs.controller_serial_number;
2891 for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++) 2897 for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
2892 adapter->serial_num[i] = le32_to_cpu(serial_num[i]) & 2898 adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
@@ -3709,7 +3715,6 @@ int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
3709 status = -EINVAL; 3715 status = -EINVAL;
3710 goto err; 3716 goto err;
3711 } 3717 }
3712
3713 adapter->pf_number = desc->pf_num; 3718 adapter->pf_number = desc->pf_num;
3714 be_copy_nic_desc(res, desc); 3719 be_copy_nic_desc(res, desc);
3715 } 3720 }
@@ -3721,7 +3726,10 @@ err:
3721 return status; 3726 return status;
3722} 3727}
3723 3728
3724/* Will use MBOX only if MCCQ has not been created */ 3729/* Will use MBOX only if MCCQ has not been created
3730 * non-zero domain => a PF is querying this on behalf of a VF
3731 * zero domain => a PF or a VF is querying this for itself
3732 */
3725int be_cmd_get_profile_config(struct be_adapter *adapter, 3733int be_cmd_get_profile_config(struct be_adapter *adapter,
3726 struct be_resources *res, u8 query, u8 domain) 3734 struct be_resources *res, u8 query, u8 domain)
3727{ 3735{
@@ -3748,10 +3756,15 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
3748 OPCODE_COMMON_GET_PROFILE_CONFIG, 3756 OPCODE_COMMON_GET_PROFILE_CONFIG,
3749 cmd.size, &wrb, &cmd); 3757 cmd.size, &wrb, &cmd);
3750 3758
3751 req->hdr.domain = domain;
3752 if (!lancer_chip(adapter)) 3759 if (!lancer_chip(adapter))
3753 req->hdr.version = 1; 3760 req->hdr.version = 1;
3754 req->type = ACTIVE_PROFILE_TYPE; 3761 req->type = ACTIVE_PROFILE_TYPE;
3762 /* When a function is querying profile information relating to
3763 * itself hdr.pf_number must be set to it's pci_func_num + 1
3764 */
3765 req->hdr.domain = domain;
3766 if (domain == 0)
3767 req->hdr.pf_num = adapter->pci_func_num + 1;
3755 3768
3756 /* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the 3769 /* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the
3757 * descriptors with all bits set to "1" for the fields which can be 3770 * descriptors with all bits set to "1" for the fields which can be
@@ -3921,12 +3934,16 @@ static void be_fill_vf_res_template(struct be_adapter *adapter,
3921 vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS | 3934 vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS |
3922 BE_IF_FLAGS_DEFQ_RSS); 3935 BE_IF_FLAGS_DEFQ_RSS);
3923 } 3936 }
3924
3925 nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags);
3926 } else { 3937 } else {
3927 num_vf_qs = 1; 3938 num_vf_qs = 1;
3928 } 3939 }
3929 3940
3941 if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
3942 nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
3943 vf_if_cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS;
3944 }
3945
3946 nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags);
3930 nic_vft->rq_count = cpu_to_le16(num_vf_qs); 3947 nic_vft->rq_count = cpu_to_le16(num_vf_qs);
3931 nic_vft->txq_count = cpu_to_le16(num_vf_qs); 3948 nic_vft->txq_count = cpu_to_le16(num_vf_qs);
3932 nic_vft->rssq_count = cpu_to_le16(num_vf_qs); 3949 nic_vft->rssq_count = cpu_to_le16(num_vf_qs);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 7d178bdb112e..91155ea74f34 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -289,7 +289,9 @@ struct be_cmd_req_hdr {
289 u32 timeout; /* dword 1 */ 289 u32 timeout; /* dword 1 */
290 u32 request_length; /* dword 2 */ 290 u32 request_length; /* dword 2 */
291 u8 version; /* dword 3 */ 291 u8 version; /* dword 3 */
292 u8 rsvd[3]; /* dword 3 */ 292 u8 rsvd1; /* dword 3 */
293 u8 pf_num; /* dword 3 */
294 u8 rsvd2; /* dword 3 */
293}; 295};
294 296
295#define RESP_HDR_INFO_OPCODE_SHIFT 0 /* bits 0 - 7 */ 297#define RESP_HDR_INFO_OPCODE_SHIFT 0 /* bits 0 - 7 */
@@ -1652,7 +1654,11 @@ struct mgmt_hba_attribs {
1652 1654
1653struct mgmt_controller_attrib { 1655struct mgmt_controller_attrib {
1654 struct mgmt_hba_attribs hba_attribs; 1656 struct mgmt_hba_attribs hba_attribs;
1655 u32 rsvd0[10]; 1657 u32 rsvd0[2];
1658 u16 rsvd1;
1659 u8 pci_func_num;
1660 u8 rsvd2;
1661 u32 rsvd3[7];
1656} __packed; 1662} __packed;
1657 1663
1658struct be_cmd_req_cntl_attribs { 1664struct be_cmd_req_cntl_attribs {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 12687bf52b95..eb48a977f8da 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1123,11 +1123,12 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
1123 struct sk_buff *skb, 1123 struct sk_buff *skb,
1124 struct be_wrb_params *wrb_params) 1124 struct be_wrb_params *wrb_params)
1125{ 1125{
1126 /* Lancer, SH-R ASICs have a bug wherein Packets that are 32 bytes or 1126 /* Lancer, SH and BE3 in SRIOV mode have a bug wherein
1127 * less may cause a transmit stall on that port. So the work-around is 1127 * packets that are 32b or less may cause a transmit stall
1128 * to pad short packets (<= 32 bytes) to a 36-byte length. 1128 * on that port. The workaround is to pad such packets
1129 * (len <= 32 bytes) to a minimum length of 36b.
1129 */ 1130 */
1130 if (unlikely(!BEx_chip(adapter) && skb->len <= 32)) { 1131 if (skb->len <= 32) {
1131 if (skb_put_padto(skb, 36)) 1132 if (skb_put_padto(skb, 36))
1132 return NULL; 1133 return NULL;
1133 } 1134 }
@@ -4205,10 +4206,6 @@ static int be_get_config(struct be_adapter *adapter)
4205 int status, level; 4206 int status, level;
4206 u16 profile_id; 4207 u16 profile_id;
4207 4208
4208 status = be_cmd_get_cntl_attributes(adapter);
4209 if (status)
4210 return status;
4211
4212 status = be_cmd_query_fw_cfg(adapter); 4209 status = be_cmd_query_fw_cfg(adapter);
4213 if (status) 4210 if (status)
4214 return status; 4211 return status;
@@ -4407,6 +4404,11 @@ static int be_setup(struct be_adapter *adapter)
4407 if (!lancer_chip(adapter)) 4404 if (!lancer_chip(adapter))
4408 be_cmd_req_native_mode(adapter); 4405 be_cmd_req_native_mode(adapter);
4409 4406
4407 /* Need to invoke this cmd first to get the PCI Function Number */
4408 status = be_cmd_get_cntl_attributes(adapter);
4409 if (status)
4410 return status;
4411
4410 if (!BE2_chip(adapter) && be_physfn(adapter)) 4412 if (!BE2_chip(adapter) && be_physfn(adapter))
4411 be_alloc_sriov_res(adapter); 4413 be_alloc_sriov_res(adapter);
4412 4414
@@ -4999,7 +5001,15 @@ static bool be_check_ufi_compatibility(struct be_adapter *adapter,
4999 return false; 5001 return false;
5000 } 5002 }
5001 5003
5002 return (fhdr->asic_type_rev >= adapter->asic_rev); 5004 /* In BE3 FW images the "asic_type_rev" field doesn't track the
5005 * asic_rev of the chips it is compatible with.
5006 * When asic_type_rev is 0 the image is compatible only with
5007 * pre-BE3-R chips (asic_rev < 0x10)
5008 */
5009 if (BEx_chip(adapter) && fhdr->asic_type_rev == 0)
5010 return adapter->asic_rev < 0x10;
5011 else
5012 return (fhdr->asic_type_rev >= adapter->asic_rev);
5003} 5013}
5004 5014
5005static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw) 5015static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw)
@@ -5176,6 +5186,11 @@ static void be_add_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
5176 if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter)) 5186 if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter))
5177 return; 5187 return;
5178 5188
5189 if (adapter->vxlan_port == port && adapter->vxlan_port_count) {
5190 adapter->vxlan_port_aliases++;
5191 return;
5192 }
5193
5179 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) { 5194 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) {
5180 dev_info(dev, 5195 dev_info(dev,
5181 "Only one UDP port supported for VxLAN offloads\n"); 5196 "Only one UDP port supported for VxLAN offloads\n");
@@ -5226,6 +5241,11 @@ static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
5226 if (adapter->vxlan_port != port) 5241 if (adapter->vxlan_port != port)
5227 goto done; 5242 goto done;
5228 5243
5244 if (adapter->vxlan_port_aliases) {
5245 adapter->vxlan_port_aliases--;
5246 return;
5247 }
5248
5229 be_disable_vxlan_offloads(adapter); 5249 be_disable_vxlan_offloads(adapter);
5230 5250
5231 dev_info(&adapter->pdev->dev, 5251 dev_info(&adapter->pdev->dev,
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 3c40f6b99224..55c36230e176 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -198,11 +198,13 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
198 198
199#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) 199#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE)
200/* 200/*
201 * Return the TBIPA address, starting from the address
202 * of the mapped GFAR MDIO registers (struct gfar)
201 * This is mildly evil, but so is our hardware for doing this. 203 * This is mildly evil, but so is our hardware for doing this.
202 * Also, we have to cast back to struct gfar because of 204 * Also, we have to cast back to struct gfar because of
203 * definition weirdness done in gianfar.h. 205 * definition weirdness done in gianfar.h.
204 */ 206 */
205static uint32_t __iomem *get_gfar_tbipa(void __iomem *p) 207static uint32_t __iomem *get_gfar_tbipa_from_mdio(void __iomem *p)
206{ 208{
207 struct gfar __iomem *enet_regs = p; 209 struct gfar __iomem *enet_regs = p;
208 210
@@ -210,6 +212,15 @@ static uint32_t __iomem *get_gfar_tbipa(void __iomem *p)
210} 212}
211 213
212/* 214/*
215 * Return the TBIPA address, starting from the address
216 * of the mapped GFAR MII registers (gfar_mii_regs[] within struct gfar)
217 */
218static uint32_t __iomem *get_gfar_tbipa_from_mii(void __iomem *p)
219{
220 return get_gfar_tbipa_from_mdio(container_of(p, struct gfar, gfar_mii_regs));
221}
222
223/*
213 * Return the TBIPAR address for an eTSEC2 node 224 * Return the TBIPAR address for an eTSEC2 node
214 */ 225 */
215static uint32_t __iomem *get_etsec_tbipa(void __iomem *p) 226static uint32_t __iomem *get_etsec_tbipa(void __iomem *p)
@@ -220,11 +231,12 @@ static uint32_t __iomem *get_etsec_tbipa(void __iomem *p)
220 231
221#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) 232#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
222/* 233/*
223 * Return the TBIPAR address for a QE MDIO node 234 * Return the TBIPAR address for a QE MDIO node, starting from the address
235 * of the mapped MII registers (struct fsl_pq_mii)
224 */ 236 */
225static uint32_t __iomem *get_ucc_tbipa(void __iomem *p) 237static uint32_t __iomem *get_ucc_tbipa(void __iomem *p)
226{ 238{
227 struct fsl_pq_mdio __iomem *mdio = p; 239 struct fsl_pq_mdio __iomem *mdio = container_of(p, struct fsl_pq_mdio, mii);
228 240
229 return &mdio->utbipar; 241 return &mdio->utbipar;
230} 242}
@@ -300,14 +312,14 @@ static const struct of_device_id fsl_pq_mdio_match[] = {
300 .compatible = "fsl,gianfar-tbi", 312 .compatible = "fsl,gianfar-tbi",
301 .data = &(struct fsl_pq_mdio_data) { 313 .data = &(struct fsl_pq_mdio_data) {
302 .mii_offset = 0, 314 .mii_offset = 0,
303 .get_tbipa = get_gfar_tbipa, 315 .get_tbipa = get_gfar_tbipa_from_mii,
304 }, 316 },
305 }, 317 },
306 { 318 {
307 .compatible = "fsl,gianfar-mdio", 319 .compatible = "fsl,gianfar-mdio",
308 .data = &(struct fsl_pq_mdio_data) { 320 .data = &(struct fsl_pq_mdio_data) {
309 .mii_offset = 0, 321 .mii_offset = 0,
310 .get_tbipa = get_gfar_tbipa, 322 .get_tbipa = get_gfar_tbipa_from_mii,
311 }, 323 },
312 }, 324 },
313 { 325 {
@@ -315,7 +327,7 @@ static const struct of_device_id fsl_pq_mdio_match[] = {
315 .compatible = "gianfar", 327 .compatible = "gianfar",
316 .data = &(struct fsl_pq_mdio_data) { 328 .data = &(struct fsl_pq_mdio_data) {
317 .mii_offset = offsetof(struct fsl_pq_mdio, mii), 329 .mii_offset = offsetof(struct fsl_pq_mdio, mii),
318 .get_tbipa = get_gfar_tbipa, 330 .get_tbipa = get_gfar_tbipa_from_mdio,
319 }, 331 },
320 }, 332 },
321 { 333 {
@@ -445,6 +457,16 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
445 457
446 tbipa = data->get_tbipa(priv->map); 458 tbipa = data->get_tbipa(priv->map);
447 459
460 /*
461 * Add consistency check to make sure TBI is contained
462 * within the mapped range (not because we would get a
463 * segfault, rather to catch bugs in computing TBI
464 * address). Print error message but continue anyway.
465 */
466 if ((void *)tbipa > priv->map + resource_size(&res) - 4)
467 dev_err(&pdev->dev, "invalid register map (should be at least 0x%04x to contain TBI address)\n",
468 ((void *)tbipa - priv->map) + 4);
469
448 iowrite32be(be32_to_cpup(prop), tbipa); 470 iowrite32be(be32_to_cpup(prop), tbipa);
449 } 471 }
450 } 472 }
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 4b69d061d90f..ce38d266f931 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -341,7 +341,7 @@ static void gfar_rx_offload_en(struct gfar_private *priv)
341 if (priv->ndev->features & (NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX)) 341 if (priv->ndev->features & (NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX))
342 priv->uses_rxfcb = 1; 342 priv->uses_rxfcb = 1;
343 343
344 if (priv->hwts_rx_en) 344 if (priv->hwts_rx_en || priv->rx_filer_enable)
345 priv->uses_rxfcb = 1; 345 priv->uses_rxfcb = 1;
346} 346}
347 347
@@ -351,7 +351,7 @@ static void gfar_mac_rx_config(struct gfar_private *priv)
351 u32 rctrl = 0; 351 u32 rctrl = 0;
352 352
353 if (priv->rx_filer_enable) { 353 if (priv->rx_filer_enable) {
354 rctrl |= RCTRL_FILREN; 354 rctrl |= RCTRL_FILREN | RCTRL_PRSDEP_INIT;
355 /* Program the RIR0 reg with the required distribution */ 355 /* Program the RIR0 reg with the required distribution */
356 if (priv->poll_mode == GFAR_SQ_POLLING) 356 if (priv->poll_mode == GFAR_SQ_POLLING)
357 gfar_write(&regs->rir0, DEFAULT_2RXQ_RIR0); 357 gfar_write(&regs->rir0, DEFAULT_2RXQ_RIR0);
@@ -1710,8 +1710,10 @@ static void gfar_configure_serdes(struct net_device *dev)
1710 * everything for us? Resetting it takes the link down and requires 1710 * everything for us? Resetting it takes the link down and requires
1711 * several seconds for it to come back. 1711 * several seconds for it to come back.
1712 */ 1712 */
1713 if (phy_read(tbiphy, MII_BMSR) & BMSR_LSTATUS) 1713 if (phy_read(tbiphy, MII_BMSR) & BMSR_LSTATUS) {
1714 put_device(&tbiphy->dev);
1714 return; 1715 return;
1716 }
1715 1717
1716 /* Single clk mode, mii mode off(for serdes communication) */ 1718 /* Single clk mode, mii mode off(for serdes communication) */
1717 phy_write(tbiphy, MII_TBICON, TBICON_CLK_SELECT); 1719 phy_write(tbiphy, MII_TBICON, TBICON_CLK_SELECT);
@@ -1723,6 +1725,8 @@ static void gfar_configure_serdes(struct net_device *dev)
1723 phy_write(tbiphy, MII_BMCR, 1725 phy_write(tbiphy, MII_BMCR,
1724 BMCR_ANENABLE | BMCR_ANRESTART | BMCR_FULLDPLX | 1726 BMCR_ANENABLE | BMCR_ANRESTART | BMCR_FULLDPLX |
1725 BMCR_SPEED1000); 1727 BMCR_SPEED1000);
1728
1729 put_device(&tbiphy->dev);
1726} 1730}
1727 1731
1728static int __gfar_is_rx_idle(struct gfar_private *priv) 1732static int __gfar_is_rx_idle(struct gfar_private *priv)
@@ -1970,8 +1974,7 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
1970 /* Install our interrupt handlers for Error, 1974 /* Install our interrupt handlers for Error,
1971 * Transmit, and Receive 1975 * Transmit, and Receive
1972 */ 1976 */
1973 err = request_irq(gfar_irq(grp, ER)->irq, gfar_error, 1977 err = request_irq(gfar_irq(grp, ER)->irq, gfar_error, 0,
1974 IRQF_NO_SUSPEND,
1975 gfar_irq(grp, ER)->name, grp); 1978 gfar_irq(grp, ER)->name, grp);
1976 if (err < 0) { 1979 if (err < 0) {
1977 netif_err(priv, intr, dev, "Can't get IRQ %d\n", 1980 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
@@ -1979,6 +1982,8 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
1979 1982
1980 goto err_irq_fail; 1983 goto err_irq_fail;
1981 } 1984 }
1985 enable_irq_wake(gfar_irq(grp, ER)->irq);
1986
1982 err = request_irq(gfar_irq(grp, TX)->irq, gfar_transmit, 0, 1987 err = request_irq(gfar_irq(grp, TX)->irq, gfar_transmit, 0,
1983 gfar_irq(grp, TX)->name, grp); 1988 gfar_irq(grp, TX)->name, grp);
1984 if (err < 0) { 1989 if (err < 0) {
@@ -1994,14 +1999,14 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
1994 goto rx_irq_fail; 1999 goto rx_irq_fail;
1995 } 2000 }
1996 } else { 2001 } else {
1997 err = request_irq(gfar_irq(grp, TX)->irq, gfar_interrupt, 2002 err = request_irq(gfar_irq(grp, TX)->irq, gfar_interrupt, 0,
1998 IRQF_NO_SUSPEND,
1999 gfar_irq(grp, TX)->name, grp); 2003 gfar_irq(grp, TX)->name, grp);
2000 if (err < 0) { 2004 if (err < 0) {
2001 netif_err(priv, intr, dev, "Can't get IRQ %d\n", 2005 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
2002 gfar_irq(grp, TX)->irq); 2006 gfar_irq(grp, TX)->irq);
2003 goto err_irq_fail; 2007 goto err_irq_fail;
2004 } 2008 }
2009 enable_irq_wake(gfar_irq(grp, TX)->irq);
2005 } 2010 }
2006 2011
2007 return 0; 2012 return 0;
@@ -3457,11 +3462,9 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
3457 netif_dbg(priv, tx_err, dev, "Transmit Error\n"); 3462 netif_dbg(priv, tx_err, dev, "Transmit Error\n");
3458 } 3463 }
3459 if (events & IEVENT_BSY) { 3464 if (events & IEVENT_BSY) {
3460 dev->stats.rx_errors++; 3465 dev->stats.rx_over_errors++;
3461 atomic64_inc(&priv->extra_stats.rx_bsy); 3466 atomic64_inc(&priv->extra_stats.rx_bsy);
3462 3467
3463 gfar_receive(irq, grp_id);
3464
3465 netif_dbg(priv, rx_err, dev, "busy error (rstat: %x)\n", 3468 netif_dbg(priv, rx_err, dev, "busy error (rstat: %x)\n",
3466 gfar_read(&regs->rstat)); 3469 gfar_read(&regs->rstat));
3467 } 3470 }
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 6bdc89179b72..a33e4a829601 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -676,14 +676,14 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
676 u32 fcr = 0x0, fpr = FPR_FILER_MASK; 676 u32 fcr = 0x0, fpr = FPR_FILER_MASK;
677 677
678 if (ethflow & RXH_L2DA) { 678 if (ethflow & RXH_L2DA) {
679 fcr = RQFCR_PID_DAH |RQFCR_CMP_NOMATCH | 679 fcr = RQFCR_PID_DAH | RQFCR_CMP_NOMATCH |
680 RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0; 680 RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0;
681 priv->ftp_rqfpr[priv->cur_filer_idx] = fpr; 681 priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
682 priv->ftp_rqfcr[priv->cur_filer_idx] = fcr; 682 priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
683 gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr); 683 gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
684 priv->cur_filer_idx = priv->cur_filer_idx - 1; 684 priv->cur_filer_idx = priv->cur_filer_idx - 1;
685 685
686 fcr = RQFCR_PID_DAL | RQFCR_AND | RQFCR_CMP_NOMATCH | 686 fcr = RQFCR_PID_DAL | RQFCR_CMP_NOMATCH |
687 RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0; 687 RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0;
688 priv->ftp_rqfpr[priv->cur_filer_idx] = fpr; 688 priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
689 priv->ftp_rqfcr[priv->cur_filer_idx] = fcr; 689 priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index 8e3cd77aa347..664d0c261269 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -557,6 +557,7 @@ static const struct of_device_id match_table[] = {
557 { .compatible = "fsl,etsec-ptp" }, 557 { .compatible = "fsl,etsec-ptp" },
558 {}, 558 {},
559}; 559};
560MODULE_DEVICE_TABLE(of, match_table);
560 561
561static struct platform_driver gianfar_ptp_driver = { 562static struct platform_driver gianfar_ptp_driver = {
562 .driver = { 563 .driver = {
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 4dd40e057f40..650f7888e32b 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -1384,6 +1384,8 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1384 value = phy_read(tbiphy, ENET_TBI_MII_CR); 1384 value = phy_read(tbiphy, ENET_TBI_MII_CR);
1385 value &= ~0x1000; /* Turn off autonegotiation */ 1385 value &= ~0x1000; /* Turn off autonegotiation */
1386 phy_write(tbiphy, ENET_TBI_MII_CR, value); 1386 phy_write(tbiphy, ENET_TBI_MII_CR, value);
1387
1388 put_device(&tbiphy->dev);
1387 } 1389 }
1388 1390
1389 init_check_frame_length_mode(ug_info->lengthCheckRx, &ug_regs->maccfg2); 1391 init_check_frame_length_mode(ug_info->lengthCheckRx, &ug_regs->maccfg2);
@@ -1702,8 +1704,10 @@ static void uec_configure_serdes(struct net_device *dev)
1702 * everything for us? Resetting it takes the link down and requires 1704 * everything for us? Resetting it takes the link down and requires
1703 * several seconds for it to come back. 1705 * several seconds for it to come back.
1704 */ 1706 */
1705 if (phy_read(tbiphy, ENET_TBI_MII_SR) & TBISR_LSTATUS) 1707 if (phy_read(tbiphy, ENET_TBI_MII_SR) & TBISR_LSTATUS) {
1708 put_device(&tbiphy->dev);
1706 return; 1709 return;
1710 }
1707 1711
1708 /* Single clk mode, mii mode off(for serdes communication) */ 1712 /* Single clk mode, mii mode off(for serdes communication) */
1709 phy_write(tbiphy, ENET_TBI_MII_ANA, TBIANA_SETTINGS); 1713 phy_write(tbiphy, ENET_TBI_MII_ANA, TBIANA_SETTINGS);
@@ -1711,6 +1715,8 @@ static void uec_configure_serdes(struct net_device *dev)
1711 phy_write(tbiphy, ENET_TBI_MII_TBICON, TBICON_CLK_SELECT); 1715 phy_write(tbiphy, ENET_TBI_MII_TBICON, TBICON_CLK_SELECT);
1712 1716
1713 phy_write(tbiphy, ENET_TBI_MII_CR, TBICR_SETTINGS); 1717 phy_write(tbiphy, ENET_TBI_MII_CR, TBICR_SETTINGS);
1718
1719 put_device(&tbiphy->dev);
1714} 1720}
1715 1721
1716/* Configure the PHY for dev. 1722/* Configure the PHY for dev.
diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index cc2d8b4b18e3..253f8ed0537a 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -816,7 +816,7 @@ static int hip04_mac_probe(struct platform_device *pdev)
816 struct net_device *ndev; 816 struct net_device *ndev;
817 struct hip04_priv *priv; 817 struct hip04_priv *priv;
818 struct resource *res; 818 struct resource *res;
819 unsigned int irq; 819 int irq;
820 int ret; 820 int ret;
821 821
822 ndev = alloc_etherdev(sizeof(struct hip04_priv)); 822 ndev = alloc_etherdev(sizeof(struct hip04_priv));
diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h
index 28df37420da9..ac02c675c59c 100644
--- a/drivers/net/ethernet/ibm/emac/core.h
+++ b/drivers/net/ethernet/ibm/emac/core.h
@@ -460,8 +460,8 @@ struct emac_ethtool_regs_subhdr {
460 u32 index; 460 u32 index;
461}; 461};
462 462
463#define EMAC_ETHTOOL_REGS_VER 0 463#define EMAC_ETHTOOL_REGS_VER 3
464#define EMAC4_ETHTOOL_REGS_VER 1 464#define EMAC4_ETHTOOL_REGS_VER 4
465#define EMAC4SYNC_ETHTOOL_REGS_VER 2 465#define EMAC4SYNC_ETHTOOL_REGS_VER 5
466 466
467#endif /* __IBM_NEWEMAC_CORE_H */ 467#endif /* __IBM_NEWEMAC_CORE_H */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index 3e0d20037675..c0e943aecd13 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -386,7 +386,6 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
386 386
387 hw->aq.asq.next_to_use = 0; 387 hw->aq.asq.next_to_use = 0;
388 hw->aq.asq.next_to_clean = 0; 388 hw->aq.asq.next_to_clean = 0;
389 hw->aq.asq.count = hw->aq.num_asq_entries;
390 389
391 /* allocate the ring memory */ 390 /* allocate the ring memory */
392 ret_code = i40e_alloc_adminq_asq_ring(hw); 391 ret_code = i40e_alloc_adminq_asq_ring(hw);
@@ -404,6 +403,7 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
404 goto init_adminq_free_rings; 403 goto init_adminq_free_rings;
405 404
406 /* success! */ 405 /* success! */
406 hw->aq.asq.count = hw->aq.num_asq_entries;
407 goto init_adminq_exit; 407 goto init_adminq_exit;
408 408
409init_adminq_free_rings: 409init_adminq_free_rings:
@@ -445,7 +445,6 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
445 445
446 hw->aq.arq.next_to_use = 0; 446 hw->aq.arq.next_to_use = 0;
447 hw->aq.arq.next_to_clean = 0; 447 hw->aq.arq.next_to_clean = 0;
448 hw->aq.arq.count = hw->aq.num_arq_entries;
449 448
450 /* allocate the ring memory */ 449 /* allocate the ring memory */
451 ret_code = i40e_alloc_adminq_arq_ring(hw); 450 ret_code = i40e_alloc_adminq_arq_ring(hw);
@@ -463,6 +462,7 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
463 goto init_adminq_free_rings; 462 goto init_adminq_free_rings;
464 463
465 /* success! */ 464 /* success! */
465 hw->aq.arq.count = hw->aq.num_arq_entries;
466 goto init_adminq_exit; 466 goto init_adminq_exit;
467 467
468init_adminq_free_rings: 468init_adminq_free_rings:
@@ -946,6 +946,13 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
946 /* take the lock before we start messing with the ring */ 946 /* take the lock before we start messing with the ring */
947 mutex_lock(&hw->aq.arq_mutex); 947 mutex_lock(&hw->aq.arq_mutex);
948 948
949 if (hw->aq.arq.count == 0) {
950 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
951 "AQRX: Admin queue not initialized.\n");
952 ret_code = I40E_ERR_QUEUE_EMPTY;
953 goto clean_arq_element_err;
954 }
955
949 /* set next_to_use to head */ 956 /* set next_to_use to head */
950 ntu = (rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK); 957 ntu = (rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK);
951 if (ntu == ntc) { 958 if (ntu == ntc) {
@@ -1007,6 +1014,8 @@ clean_arq_element_out:
1007 /* Set pending if needed, unlock and return */ 1014 /* Set pending if needed, unlock and return */
1008 if (pending != NULL) 1015 if (pending != NULL)
1009 *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc); 1016 *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
1017
1018clean_arq_element_err:
1010 mutex_unlock(&hw->aq.arq_mutex); 1019 mutex_unlock(&hw->aq.arq_mutex);
1011 1020
1012 if (i40e_is_nvm_update_op(&e->desc)) { 1021 if (i40e_is_nvm_update_op(&e->desc)) {
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index e972b5ecbf0b..13a5d4cf494b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -1344,6 +1344,12 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
1344 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat == 1344 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
1345 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; 1345 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1346 } 1346 }
1347 for (j = 0; j < I40E_MAX_TRAFFIC_CLASS; j++) {
1348 data[i++] = veb->tc_stats.tc_tx_packets[j];
1349 data[i++] = veb->tc_stats.tc_tx_bytes[j];
1350 data[i++] = veb->tc_stats.tc_rx_packets[j];
1351 data[i++] = veb->tc_stats.tc_rx_bytes[j];
1352 }
1347 } 1353 }
1348 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) { 1354 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
1349 p = (char *)pf + i40e_gstrings_stats[j].stat_offset; 1355 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 851c1a159be8..3dd26cdd0bf2 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2672,7 +2672,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
2672 rx_ctx.lrxqthresh = 2; 2672 rx_ctx.lrxqthresh = 2;
2673 rx_ctx.crcstrip = 1; 2673 rx_ctx.crcstrip = 1;
2674 rx_ctx.l2tsel = 1; 2674 rx_ctx.l2tsel = 1;
2675 rx_ctx.showiv = 1; 2675 /* this controls whether VLAN is stripped from inner headers */
2676 rx_ctx.showiv = 0;
2676#ifdef I40E_FCOE 2677#ifdef I40E_FCOE
2677 rx_ctx.fc_ena = (vsi->type == I40E_VSI_FCOE); 2678 rx_ctx.fc_ena = (vsi->type == I40E_VSI_FCOE);
2678#endif 2679#endif
@@ -7910,6 +7911,7 @@ static int i40e_sw_init(struct i40e_pf *pf)
7910 if (pf->hw.func_caps.vmdq) { 7911 if (pf->hw.func_caps.vmdq) {
7911 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI; 7912 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI;
7912 pf->flags |= I40E_FLAG_VMDQ_ENABLED; 7913 pf->flags |= I40E_FLAG_VMDQ_ENABLED;
7914 pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf);
7913 } 7915 }
7914 7916
7915#ifdef I40E_FCOE 7917#ifdef I40E_FCOE
@@ -8388,6 +8390,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
8388 8390
8389 netdev->hw_enc_features |= NETIF_F_IP_CSUM | 8391 netdev->hw_enc_features |= NETIF_F_IP_CSUM |
8390 NETIF_F_GSO_UDP_TUNNEL | 8392 NETIF_F_GSO_UDP_TUNNEL |
8393 NETIF_F_GSO_GRE |
8391 NETIF_F_TSO; 8394 NETIF_F_TSO;
8392 8395
8393 netdev->features = NETIF_F_SG | 8396 netdev->features = NETIF_F_SG |
@@ -8395,6 +8398,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
8395 NETIF_F_SCTP_CSUM | 8398 NETIF_F_SCTP_CSUM |
8396 NETIF_F_HIGHDMA | 8399 NETIF_F_HIGHDMA |
8397 NETIF_F_GSO_UDP_TUNNEL | 8400 NETIF_F_GSO_UDP_TUNNEL |
8401 NETIF_F_GSO_GRE |
8398 NETIF_F_HW_VLAN_CTAG_TX | 8402 NETIF_F_HW_VLAN_CTAG_TX |
8399 NETIF_F_HW_VLAN_CTAG_RX | 8403 NETIF_F_HW_VLAN_CTAG_RX |
8400 NETIF_F_HW_VLAN_CTAG_FILTER | 8404 NETIF_F_HW_VLAN_CTAG_FILTER |
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
index f08450b90774..a23ebfd5cd25 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
@@ -373,7 +373,6 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
373 373
374 hw->aq.asq.next_to_use = 0; 374 hw->aq.asq.next_to_use = 0;
375 hw->aq.asq.next_to_clean = 0; 375 hw->aq.asq.next_to_clean = 0;
376 hw->aq.asq.count = hw->aq.num_asq_entries;
377 376
378 /* allocate the ring memory */ 377 /* allocate the ring memory */
379 ret_code = i40e_alloc_adminq_asq_ring(hw); 378 ret_code = i40e_alloc_adminq_asq_ring(hw);
@@ -391,6 +390,7 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw)
391 goto init_adminq_free_rings; 390 goto init_adminq_free_rings;
392 391
393 /* success! */ 392 /* success! */
393 hw->aq.asq.count = hw->aq.num_asq_entries;
394 goto init_adminq_exit; 394 goto init_adminq_exit;
395 395
396init_adminq_free_rings: 396init_adminq_free_rings:
@@ -432,7 +432,6 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
432 432
433 hw->aq.arq.next_to_use = 0; 433 hw->aq.arq.next_to_use = 0;
434 hw->aq.arq.next_to_clean = 0; 434 hw->aq.arq.next_to_clean = 0;
435 hw->aq.arq.count = hw->aq.num_arq_entries;
436 435
437 /* allocate the ring memory */ 436 /* allocate the ring memory */
438 ret_code = i40e_alloc_adminq_arq_ring(hw); 437 ret_code = i40e_alloc_adminq_arq_ring(hw);
@@ -450,6 +449,7 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw)
450 goto init_adminq_free_rings; 449 goto init_adminq_free_rings;
451 450
452 /* success! */ 451 /* success! */
452 hw->aq.arq.count = hw->aq.num_arq_entries;
453 goto init_adminq_exit; 453 goto init_adminq_exit;
454 454
455init_adminq_free_rings: 455init_adminq_free_rings:
@@ -887,6 +887,13 @@ i40e_status i40evf_clean_arq_element(struct i40e_hw *hw,
887 /* take the lock before we start messing with the ring */ 887 /* take the lock before we start messing with the ring */
888 mutex_lock(&hw->aq.arq_mutex); 888 mutex_lock(&hw->aq.arq_mutex);
889 889
890 if (hw->aq.arq.count == 0) {
891 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
892 "AQRX: Admin queue not initialized.\n");
893 ret_code = I40E_ERR_QUEUE_EMPTY;
894 goto clean_arq_element_err;
895 }
896
890 /* set next_to_use to head */ 897 /* set next_to_use to head */
891 ntu = (rd32(hw, hw->aq.arq.head) & I40E_VF_ARQH1_ARQH_MASK); 898 ntu = (rd32(hw, hw->aq.arq.head) & I40E_VF_ARQH1_ARQH_MASK);
892 if (ntu == ntc) { 899 if (ntu == ntc) {
@@ -948,6 +955,8 @@ clean_arq_element_out:
948 /* Set pending if needed, unlock and return */ 955 /* Set pending if needed, unlock and return */
949 if (pending != NULL) 956 if (pending != NULL)
950 *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc); 957 *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
958
959clean_arq_element_err:
951 mutex_unlock(&hw->aq.arq_mutex); 960 mutex_unlock(&hw->aq.arq_mutex);
952 961
953 return ret_code; 962 return ret_code;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 960169efe636..dfb6d5f79a10 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -759,11 +759,23 @@ txq_put_data_tso(struct net_device *dev, struct tx_queue *txq,
759 759
760 desc->l4i_chk = 0; 760 desc->l4i_chk = 0;
761 desc->byte_cnt = length; 761 desc->byte_cnt = length;
762 desc->buf_ptr = dma_map_single(dev->dev.parent, data, 762
763 length, DMA_TO_DEVICE); 763 if (length <= 8 && (uintptr_t)data & 0x7) {
764 if (unlikely(dma_mapping_error(dev->dev.parent, desc->buf_ptr))) { 764 /* Copy unaligned small data fragment to TSO header data area */
765 WARN(1, "dma_map_single failed!\n"); 765 memcpy(txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE,
766 return -ENOMEM; 766 data, length);
767 desc->buf_ptr = txq->tso_hdrs_dma
768 + txq->tx_curr_desc * TSO_HEADER_SIZE;
769 } else {
770 /* Alignment is okay, map buffer and hand off to hardware */
771 txq->tx_desc_mapping[tx_index] = DESC_DMA_MAP_SINGLE;
772 desc->buf_ptr = dma_map_single(dev->dev.parent, data,
773 length, DMA_TO_DEVICE);
774 if (unlikely(dma_mapping_error(dev->dev.parent,
775 desc->buf_ptr))) {
776 WARN(1, "dma_map_single failed!\n");
777 return -ENOMEM;
778 }
767 } 779 }
768 780
769 cmd_sts = BUFFER_OWNED_BY_DMA; 781 cmd_sts = BUFFER_OWNED_BY_DMA;
@@ -779,7 +791,8 @@ txq_put_data_tso(struct net_device *dev, struct tx_queue *txq,
779} 791}
780 792
781static inline void 793static inline void
782txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length) 794txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length,
795 u32 *first_cmd_sts, bool first_desc)
783{ 796{
784 struct mv643xx_eth_private *mp = txq_to_mp(txq); 797 struct mv643xx_eth_private *mp = txq_to_mp(txq);
785 int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 798 int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
@@ -788,6 +801,7 @@ txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length)
788 int ret; 801 int ret;
789 u32 cmd_csum = 0; 802 u32 cmd_csum = 0;
790 u16 l4i_chk = 0; 803 u16 l4i_chk = 0;
804 u32 cmd_sts;
791 805
792 tx_index = txq->tx_curr_desc; 806 tx_index = txq->tx_curr_desc;
793 desc = &txq->tx_desc_area[tx_index]; 807 desc = &txq->tx_desc_area[tx_index];
@@ -803,9 +817,17 @@ txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length)
803 desc->byte_cnt = hdr_len; 817 desc->byte_cnt = hdr_len;
804 desc->buf_ptr = txq->tso_hdrs_dma + 818 desc->buf_ptr = txq->tso_hdrs_dma +
805 txq->tx_curr_desc * TSO_HEADER_SIZE; 819 txq->tx_curr_desc * TSO_HEADER_SIZE;
806 desc->cmd_sts = cmd_csum | BUFFER_OWNED_BY_DMA | TX_FIRST_DESC | 820 cmd_sts = cmd_csum | BUFFER_OWNED_BY_DMA | TX_FIRST_DESC |
807 GEN_CRC; 821 GEN_CRC;
808 822
823 /* Defer updating the first command descriptor until all
824 * following descriptors have been written.
825 */
826 if (first_desc)
827 *first_cmd_sts = cmd_sts;
828 else
829 desc->cmd_sts = cmd_sts;
830
809 txq->tx_curr_desc++; 831 txq->tx_curr_desc++;
810 if (txq->tx_curr_desc == txq->tx_ring_size) 832 if (txq->tx_curr_desc == txq->tx_ring_size)
811 txq->tx_curr_desc = 0; 833 txq->tx_curr_desc = 0;
@@ -819,6 +841,8 @@ static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb,
819 int desc_count = 0; 841 int desc_count = 0;
820 struct tso_t tso; 842 struct tso_t tso;
821 int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 843 int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
844 struct tx_desc *first_tx_desc;
845 u32 first_cmd_sts = 0;
822 846
823 /* Count needed descriptors */ 847 /* Count needed descriptors */
824 if ((txq->tx_desc_count + tso_count_descs(skb)) >= txq->tx_ring_size) { 848 if ((txq->tx_desc_count + tso_count_descs(skb)) >= txq->tx_ring_size) {
@@ -826,11 +850,14 @@ static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb,
826 return -EBUSY; 850 return -EBUSY;
827 } 851 }
828 852
853 first_tx_desc = &txq->tx_desc_area[txq->tx_curr_desc];
854
829 /* Initialize the TSO handler, and prepare the first payload */ 855 /* Initialize the TSO handler, and prepare the first payload */
830 tso_start(skb, &tso); 856 tso_start(skb, &tso);
831 857
832 total_len = skb->len - hdr_len; 858 total_len = skb->len - hdr_len;
833 while (total_len > 0) { 859 while (total_len > 0) {
860 bool first_desc = (desc_count == 0);
834 char *hdr; 861 char *hdr;
835 862
836 data_left = min_t(int, skb_shinfo(skb)->gso_size, total_len); 863 data_left = min_t(int, skb_shinfo(skb)->gso_size, total_len);
@@ -840,7 +867,8 @@ static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb,
840 /* prepare packet headers: MAC + IP + TCP */ 867 /* prepare packet headers: MAC + IP + TCP */
841 hdr = txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE; 868 hdr = txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE;
842 tso_build_hdr(skb, hdr, &tso, data_left, total_len == 0); 869 tso_build_hdr(skb, hdr, &tso, data_left, total_len == 0);
843 txq_put_hdr_tso(skb, txq, data_left); 870 txq_put_hdr_tso(skb, txq, data_left, &first_cmd_sts,
871 first_desc);
844 872
845 while (data_left > 0) { 873 while (data_left > 0) {
846 int size; 874 int size;
@@ -860,6 +888,10 @@ static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb,
860 __skb_queue_tail(&txq->tx_skb, skb); 888 __skb_queue_tail(&txq->tx_skb, skb);
861 skb_tx_timestamp(skb); 889 skb_tx_timestamp(skb);
862 890
891 /* ensure all other descriptors are written before first cmd_sts */
892 wmb();
893 first_tx_desc->cmd_sts = first_cmd_sts;
894
863 /* clear TX_END status */ 895 /* clear TX_END status */
864 mp->work_tx_end &= ~(1 << txq->index); 896 mp->work_tx_end &= ~(1 << txq->index);
865 897
@@ -2785,8 +2817,10 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
2785 2817
2786 for_each_available_child_of_node(np, pnp) { 2818 for_each_available_child_of_node(np, pnp) {
2787 ret = mv643xx_eth_shared_of_add_port(pdev, pnp); 2819 ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
2788 if (ret) 2820 if (ret) {
2821 of_node_put(pnp);
2789 return ret; 2822 return ret;
2823 }
2790 } 2824 }
2791 return 0; 2825 return 0;
2792} 2826}
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index fe2299ac4f5c..514df76fc70f 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1479,6 +1479,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
1479 struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq); 1479 struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq);
1480 struct sk_buff *skb; 1480 struct sk_buff *skb;
1481 unsigned char *data; 1481 unsigned char *data;
1482 dma_addr_t phys_addr;
1482 u32 rx_status; 1483 u32 rx_status;
1483 int rx_bytes, err; 1484 int rx_bytes, err;
1484 1485
@@ -1486,6 +1487,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
1486 rx_status = rx_desc->status; 1487 rx_status = rx_desc->status;
1487 rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE); 1488 rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
1488 data = (unsigned char *)rx_desc->buf_cookie; 1489 data = (unsigned char *)rx_desc->buf_cookie;
1490 phys_addr = rx_desc->buf_phys_addr;
1489 1491
1490 if (!mvneta_rxq_desc_is_first_last(rx_status) || 1492 if (!mvneta_rxq_desc_is_first_last(rx_status) ||
1491 (rx_status & MVNETA_RXD_ERR_SUMMARY)) { 1493 (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
@@ -1534,7 +1536,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
1534 if (!skb) 1536 if (!skb)
1535 goto err_drop_frame; 1537 goto err_drop_frame;
1536 1538
1537 dma_unmap_single(dev->dev.parent, rx_desc->buf_phys_addr, 1539 dma_unmap_single(dev->dev.parent, phys_addr,
1538 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE); 1540 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
1539 1541
1540 rcvd_pkts++; 1542 rcvd_pkts++;
@@ -3173,6 +3175,8 @@ static int mvneta_probe(struct platform_device *pdev)
3173 struct phy_device *phy = of_phy_find_device(dn); 3175 struct phy_device *phy = of_phy_find_device(dn);
3174 3176
3175 mvneta_fixed_link_update(pp, phy); 3177 mvneta_fixed_link_update(pp, phy);
3178
3179 put_device(&phy->dev);
3176 } 3180 }
3177 3181
3178 return 0; 3182 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 0a3202047569..2177e56ed0be 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2398,7 +2398,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
2398 } 2398 }
2399 } 2399 }
2400 2400
2401 memset(&priv->mfunc.master.cmd_eqe, 0, dev->caps.eqe_size); 2401 memset(&priv->mfunc.master.cmd_eqe, 0, sizeof(struct mlx4_eqe));
2402 priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD; 2402 priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD;
2403 INIT_WORK(&priv->mfunc.master.comm_work, 2403 INIT_WORK(&priv->mfunc.master.comm_work,
2404 mlx4_master_comm_channel); 2404 mlx4_master_comm_channel);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 4402a1e48c9b..e7a5000aa12c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -1047,13 +1047,15 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
1047 1047
1048 /* If we used up all the quota - we're probably not done yet... */ 1048 /* If we used up all the quota - we're probably not done yet... */
1049 if (done == budget) { 1049 if (done == budget) {
1050 int cpu_curr;
1051 const struct cpumask *aff; 1050 const struct cpumask *aff;
1051 struct irq_data *idata;
1052 int cpu_curr;
1052 1053
1053 INC_PERF_COUNTER(priv->pstats.napi_quota); 1054 INC_PERF_COUNTER(priv->pstats.napi_quota);
1054 1055
1055 cpu_curr = smp_processor_id(); 1056 cpu_curr = smp_processor_id();
1056 aff = irq_desc_get_irq_data(cq->irq_desc)->affinity; 1057 idata = irq_desc_get_irq_data(cq->irq_desc);
1058 aff = irq_data_get_affinity_mask(idata);
1057 1059
1058 if (likely(cpumask_test_cpu(cpu_curr, aff))) 1060 if (likely(cpumask_test_cpu(cpu_curr, aff)))
1059 return budget; 1061 return budget;
@@ -1268,8 +1270,6 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
1268 rss_context->hash_fn = MLX4_RSS_HASH_TOP; 1270 rss_context->hash_fn = MLX4_RSS_HASH_TOP;
1269 memcpy(rss_context->rss_key, priv->rss_key, 1271 memcpy(rss_context->rss_key, priv->rss_key,
1270 MLX4_EN_RSS_KEY_SIZE); 1272 MLX4_EN_RSS_KEY_SIZE);
1271 netdev_rss_key_fill(rss_context->rss_key,
1272 MLX4_EN_RSS_KEY_SIZE);
1273 } else { 1273 } else {
1274 en_err(priv, "Unknown RSS hash function requested\n"); 1274 en_err(priv, "Unknown RSS hash function requested\n");
1275 err = -EINVAL; 1275 err = -EINVAL;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 494e7762fdb1..4421bf5463f6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -964,6 +964,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
964 tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_SVLAN; 964 tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_SVLAN;
965 else if (vlan_proto == ETH_P_8021Q) 965 else if (vlan_proto == ETH_P_8021Q)
966 tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_CVLAN; 966 tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_CVLAN;
967 else
968 tx_desc->ctrl.ins_vlan = 0;
967 969
968 tx_desc->ctrl.fence_size = real_size; 970 tx_desc->ctrl.fence_size = real_size;
969 971
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 8e81e53c370e..603d1c3d3b2e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -196,7 +196,7 @@ static void slave_event(struct mlx4_dev *dev, u8 slave, struct mlx4_eqe *eqe)
196 return; 196 return;
197 } 197 }
198 198
199 memcpy(s_eqe, eqe, dev->caps.eqe_size - 1); 199 memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1);
200 s_eqe->slave_id = slave; 200 s_eqe->slave_id = slave;
201 /* ensure all information is written before setting the ownersip bit */ 201 /* ensure all information is written before setting the ownersip bit */
202 dma_wmb(); 202 dma_wmb();
@@ -1364,6 +1364,10 @@ int mlx4_test_interrupts(struct mlx4_dev *dev)
1364 * and performing a NOP command 1364 * and performing a NOP command
1365 */ 1365 */
1366 for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) { 1366 for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) {
1367 /* Make sure request_irq was called */
1368 if (!priv->eq_table.eq[i].have_irq)
1369 continue;
1370
1367 /* Temporary use polling for command completions */ 1371 /* Temporary use polling for command completions */
1368 mlx4_cmd_use_polling(dev); 1372 mlx4_cmd_use_polling(dev);
1369 1373
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 006757f80988..cc3a9897574c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2669,14 +2669,11 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
2669 2669
2670 if (msi_x) { 2670 if (msi_x) {
2671 int nreq = dev->caps.num_ports * num_online_cpus() + 1; 2671 int nreq = dev->caps.num_ports * num_online_cpus() + 1;
2672 bool shared_ports = false;
2673 2672
2674 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, 2673 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
2675 nreq); 2674 nreq);
2676 if (nreq > MAX_MSIX) { 2675 if (nreq > MAX_MSIX)
2677 nreq = MAX_MSIX; 2676 nreq = MAX_MSIX;
2678 shared_ports = true;
2679 }
2680 2677
2681 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); 2678 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
2682 if (!entries) 2679 if (!entries)
@@ -2699,9 +2696,6 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
2699 bitmap_zero(priv->eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports, 2696 bitmap_zero(priv->eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports,
2700 dev->caps.num_ports); 2697 dev->caps.num_ports);
2701 2698
2702 if (MLX4_IS_LEGACY_EQ_MODE(dev->caps))
2703 shared_ports = true;
2704
2705 for (i = 0; i < dev->caps.num_comp_vectors + 1; i++) { 2699 for (i = 0; i < dev->caps.num_comp_vectors + 1; i++) {
2706 if (i == MLX4_EQ_ASYNC) 2700 if (i == MLX4_EQ_ASYNC)
2707 continue; 2701 continue;
@@ -2709,7 +2703,7 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
2709 priv->eq_table.eq[i].irq = 2703 priv->eq_table.eq[i].irq =
2710 entries[i + 1 - !!(i > MLX4_EQ_ASYNC)].vector; 2704 entries[i + 1 - !!(i > MLX4_EQ_ASYNC)].vector;
2711 2705
2712 if (shared_ports) { 2706 if (MLX4_IS_LEGACY_EQ_MODE(dev->caps)) {
2713 bitmap_fill(priv->eq_table.eq[i].actv_ports.ports, 2707 bitmap_fill(priv->eq_table.eq[i].actv_ports.ports,
2714 dev->caps.num_ports); 2708 dev->caps.num_ports);
2715 /* We don't set affinity hint when there 2709 /* We don't set affinity hint when there
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index bd9ea0d01aae..1d4e2e054647 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -1184,10 +1184,11 @@ out:
1184 if (prot == MLX4_PROT_ETH) { 1184 if (prot == MLX4_PROT_ETH) {
1185 /* manage the steering entry for promisc mode */ 1185 /* manage the steering entry for promisc mode */
1186 if (new_entry) 1186 if (new_entry)
1187 new_steering_entry(dev, port, steer, index, qp->qpn); 1187 err = new_steering_entry(dev, port, steer,
1188 index, qp->qpn);
1188 else 1189 else
1189 existing_steering_entry(dev, port, steer, 1190 err = existing_steering_entry(dev, port, steer,
1190 index, qp->qpn); 1191 index, qp->qpn);
1191 } 1192 }
1192 if (err && link && index != -1) { 1193 if (err && link && index != -1) {
1193 if (index < dev->caps.num_mgms) 1194 if (index < dev->caps.num_mgms)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c b/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c
index e71563ce05d1..22d603f78273 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c
@@ -598,6 +598,8 @@ void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv)
598 return; 598 return;
599 599
600 priv->vlan.filter_disabled = false; 600 priv->vlan.filter_disabled = false;
601 if (priv->netdev->flags & IFF_PROMISC)
602 return;
601 mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0); 603 mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0);
602} 604}
603 605
@@ -607,6 +609,8 @@ void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv)
607 return; 609 return;
608 610
609 priv->vlan.filter_disabled = true; 611 priv->vlan.filter_disabled = true;
612 if (priv->netdev->flags & IFF_PROMISC)
613 return;
610 mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0); 614 mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0);
611} 615}
612 616
@@ -717,8 +721,12 @@ void mlx5e_set_rx_mode_work(struct work_struct *work)
717 bool enable_broadcast = !ea->broadcast_enabled && broadcast_enabled; 721 bool enable_broadcast = !ea->broadcast_enabled && broadcast_enabled;
718 bool disable_broadcast = ea->broadcast_enabled && !broadcast_enabled; 722 bool disable_broadcast = ea->broadcast_enabled && !broadcast_enabled;
719 723
720 if (enable_promisc) 724 if (enable_promisc) {
721 mlx5e_add_eth_addr_rule(priv, &ea->promisc, MLX5E_PROMISC); 725 mlx5e_add_eth_addr_rule(priv, &ea->promisc, MLX5E_PROMISC);
726 if (!priv->vlan.filter_disabled)
727 mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID,
728 0);
729 }
722 if (enable_allmulti) 730 if (enable_allmulti)
723 mlx5e_add_eth_addr_rule(priv, &ea->allmulti, MLX5E_ALLMULTI); 731 mlx5e_add_eth_addr_rule(priv, &ea->allmulti, MLX5E_ALLMULTI);
724 if (enable_broadcast) 732 if (enable_broadcast)
@@ -730,8 +738,12 @@ void mlx5e_set_rx_mode_work(struct work_struct *work)
730 mlx5e_del_eth_addr_from_flow_table(priv, &ea->broadcast); 738 mlx5e_del_eth_addr_from_flow_table(priv, &ea->broadcast);
731 if (disable_allmulti) 739 if (disable_allmulti)
732 mlx5e_del_eth_addr_from_flow_table(priv, &ea->allmulti); 740 mlx5e_del_eth_addr_from_flow_table(priv, &ea->allmulti);
733 if (disable_promisc) 741 if (disable_promisc) {
742 if (!priv->vlan.filter_disabled)
743 mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID,
744 0);
734 mlx5e_del_eth_addr_from_flow_table(priv, &ea->promisc); 745 mlx5e_del_eth_addr_from_flow_table(priv, &ea->promisc);
746 }
735 747
736 ea->promisc_enabled = promisc_enabled; 748 ea->promisc_enabled = promisc_enabled;
737 ea->allmulti_enabled = allmulti_enabled; 749 ea->allmulti_enabled = allmulti_enabled;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
index aa0d5ffe92d8..9335e5ae18cc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
@@ -200,25 +200,3 @@ int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev)
200 200
201 return err; 201 return err;
202} 202}
203
204int mlx5_core_query_special_context(struct mlx5_core_dev *dev, u32 *rsvd_lkey)
205{
206 struct mlx5_cmd_query_special_contexts_mbox_in in;
207 struct mlx5_cmd_query_special_contexts_mbox_out out;
208 int err;
209
210 memset(&in, 0, sizeof(in));
211 memset(&out, 0, sizeof(out));
212 in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS);
213 err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
214 if (err)
215 return err;
216
217 if (out.hdr.status)
218 err = mlx5_cmd_status_to_err(&out.hdr);
219
220 *rsvd_lkey = be32_to_cpu(out.resd_lkey);
221
222 return err;
223}
224EXPORT_SYMBOL(mlx5_core_query_special_context);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c
index 821caaab9bfb..3b9480fa3403 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
@@ -311,7 +311,7 @@ static int mlx5_query_port_pvlc(struct mlx5_core_dev *dev, u32 *pvlc,
311 int err; 311 int err;
312 312
313 memset(in, 0, sizeof(in)); 313 memset(in, 0, sizeof(in));
314 MLX5_SET(ptys_reg, in, local_port, local_port); 314 MLX5_SET(pvlc_reg, in, local_port, local_port);
315 315
316 err = mlx5_core_access_reg(dev, in, sizeof(in), pvlc, 316 err = mlx5_core_access_reg(dev, in, sizeof(in), pvlc,
317 pvlc_size, MLX5_REG_PVLC, 0, 0); 317 pvlc_size, MLX5_REG_PVLC, 0, 0);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index dbcaf5df8967..28c19cc1a17c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -374,26 +374,31 @@ static int __mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core,
374 int err; 374 int err;
375 int ret; 375 int ret;
376 376
377 mlxsw_core->emad.trans_active = true;
378
377 err = mlxsw_core_skb_transmit(mlxsw_core->driver_priv, skb, tx_info); 379 err = mlxsw_core_skb_transmit(mlxsw_core->driver_priv, skb, tx_info);
378 if (err) { 380 if (err) {
379 dev_err(mlxsw_core->bus_info->dev, "Failed to transmit EMAD (tid=%llx)\n", 381 dev_err(mlxsw_core->bus_info->dev, "Failed to transmit EMAD (tid=%llx)\n",
380 mlxsw_core->emad.tid); 382 mlxsw_core->emad.tid);
381 dev_kfree_skb(skb); 383 dev_kfree_skb(skb);
382 return err; 384 goto trans_inactive_out;
383 } 385 }
384 386
385 mlxsw_core->emad.trans_active = true;
386 ret = wait_event_timeout(mlxsw_core->emad.wait, 387 ret = wait_event_timeout(mlxsw_core->emad.wait,
387 !(mlxsw_core->emad.trans_active), 388 !(mlxsw_core->emad.trans_active),
388 msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS)); 389 msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS));
389 if (!ret) { 390 if (!ret) {
390 dev_warn(mlxsw_core->bus_info->dev, "EMAD timed-out (tid=%llx)\n", 391 dev_warn(mlxsw_core->bus_info->dev, "EMAD timed-out (tid=%llx)\n",
391 mlxsw_core->emad.tid); 392 mlxsw_core->emad.tid);
392 mlxsw_core->emad.trans_active = false; 393 err = -EIO;
393 return -EIO; 394 goto trans_inactive_out;
394 } 395 }
395 396
396 return 0; 397 return 0;
398
399trans_inactive_out:
400 mlxsw_core->emad.trans_active = false;
401 return err;
397} 402}
398 403
399static int mlxsw_emad_process_status(struct mlxsw_core *mlxsw_core, 404static int mlxsw_emad_process_status(struct mlxsw_core *mlxsw_core,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h
index ffd55d030ce2..36fb1cec53c9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/item.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/item.h
@@ -187,6 +187,7 @@ __mlxsw_item_bit_array_offset(struct mlxsw_item *item, u16 index, u8 *shift)
187{ 187{
188 u16 max_index, be_index; 188 u16 max_index, be_index;
189 u16 offset; /* byte offset inside the array */ 189 u16 offset; /* byte offset inside the array */
190 u8 in_byte_index;
190 191
191 BUG_ON(index && !item->element_size); 192 BUG_ON(index && !item->element_size);
192 if (item->offset % sizeof(u32) != 0 || 193 if (item->offset % sizeof(u32) != 0 ||
@@ -199,7 +200,8 @@ __mlxsw_item_bit_array_offset(struct mlxsw_item *item, u16 index, u8 *shift)
199 max_index = (item->size.bytes << 3) / item->element_size - 1; 200 max_index = (item->size.bytes << 3) / item->element_size - 1;
200 be_index = max_index - index; 201 be_index = max_index - index;
201 offset = be_index * item->element_size >> 3; 202 offset = be_index * item->element_size >> 3;
202 *shift = index % (BITS_PER_BYTE / item->element_size) << 1; 203 in_byte_index = index % (BITS_PER_BYTE / item->element_size);
204 *shift = in_byte_index * item->element_size;
203 205
204 return item->offset + offset; 206 return item->offset + offset;
205} 207}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index 462cea31ecbb..cef866c37648 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -1582,11 +1582,11 @@ static int mlxsw_pci_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod,
1582 1582
1583 if (in_mbox) 1583 if (in_mbox)
1584 memcpy(mlxsw_pci->cmd.in_mbox.buf, in_mbox, in_mbox_size); 1584 memcpy(mlxsw_pci->cmd.in_mbox.buf, in_mbox, in_mbox_size);
1585 mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_HI, in_mapaddr >> 32); 1585 mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_HI, upper_32_bits(in_mapaddr));
1586 mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_LO, in_mapaddr); 1586 mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_LO, lower_32_bits(in_mapaddr));
1587 1587
1588 mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_HI, out_mapaddr >> 32); 1588 mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_HI, upper_32_bits(out_mapaddr));
1589 mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_LO, out_mapaddr); 1589 mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_LO, lower_32_bits(out_mapaddr));
1590 1590
1591 mlxsw_pci_write32(mlxsw_pci, CIR_IN_MODIFIER, in_mod); 1591 mlxsw_pci_write32(mlxsw_pci, CIR_IN_MODIFIER, in_mod);
1592 mlxsw_pci_write32(mlxsw_pci, CIR_TOKEN, 0); 1592 mlxsw_pci_write32(mlxsw_pci, CIR_TOKEN, 0);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 3e52ee93438c..62cbbd1ada8d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -1069,9 +1069,9 @@ static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port)
1069 return 0; 1069 return 0;
1070 1070
1071err_register_netdev: 1071err_register_netdev:
1072err_port_admin_status_set:
1073err_port_mac_learning_mode_set: 1072err_port_mac_learning_mode_set:
1074err_port_stp_state_set: 1073err_port_stp_state_set:
1074err_port_admin_status_set:
1075err_port_mtu_set: 1075err_port_mtu_set:
1076err_port_speed_set: 1076err_port_speed_set:
1077err_port_swid_set: 1077err_port_swid_set:
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 37b466a4841d..1edc973df4c4 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -1601,6 +1601,7 @@ static const struct of_device_id ks8851_match_table[] = {
1601 { .compatible = "micrel,ks8851" }, 1601 { .compatible = "micrel,ks8851" },
1602 { } 1602 { }
1603}; 1603};
1604MODULE_DEVICE_TABLE(of, ks8851_match_table);
1604 1605
1605static struct spi_driver ks8851_driver = { 1606static struct spi_driver ks8851_driver = {
1606 .driver = { 1607 .driver = {
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index becbb5f1f5a7..a10c928bbd6b 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -552,6 +552,7 @@ static const struct of_device_id moxart_mac_match[] = {
552 { .compatible = "moxa,moxart-mac" }, 552 { .compatible = "moxa,moxart-mac" },
553 { } 553 { }
554}; 554};
555MODULE_DEVICE_TABLE(of, moxart_mac_match);
555 556
556static struct platform_driver moxart_mac_driver = { 557static struct platform_driver moxart_mac_driver = {
557 .probe = moxart_mac_probe, 558 .probe = moxart_mac_probe,
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index a41bb5e6b954..75e88f4c1531 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -4076,6 +4076,8 @@ static void nv_do_nic_poll(unsigned long data)
4076 struct fe_priv *np = netdev_priv(dev); 4076 struct fe_priv *np = netdev_priv(dev);
4077 u8 __iomem *base = get_hwbase(dev); 4077 u8 __iomem *base = get_hwbase(dev);
4078 u32 mask = 0; 4078 u32 mask = 0;
4079 unsigned long flags;
4080 unsigned int irq = 0;
4079 4081
4080 /* 4082 /*
4081 * First disable irq(s) and then 4083 * First disable irq(s) and then
@@ -4085,25 +4087,27 @@ static void nv_do_nic_poll(unsigned long data)
4085 4087
4086 if (!using_multi_irqs(dev)) { 4088 if (!using_multi_irqs(dev)) {
4087 if (np->msi_flags & NV_MSI_X_ENABLED) 4089 if (np->msi_flags & NV_MSI_X_ENABLED)
4088 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); 4090 irq = np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector;
4089 else 4091 else
4090 disable_irq_lockdep(np->pci_dev->irq); 4092 irq = np->pci_dev->irq;
4091 mask = np->irqmask; 4093 mask = np->irqmask;
4092 } else { 4094 } else {
4093 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { 4095 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
4094 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); 4096 irq = np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector;
4095 mask |= NVREG_IRQ_RX_ALL; 4097 mask |= NVREG_IRQ_RX_ALL;
4096 } 4098 }
4097 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) { 4099 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
4098 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); 4100 irq = np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector;
4099 mask |= NVREG_IRQ_TX_ALL; 4101 mask |= NVREG_IRQ_TX_ALL;
4100 } 4102 }
4101 if (np->nic_poll_irq & NVREG_IRQ_OTHER) { 4103 if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
4102 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); 4104 irq = np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector;
4103 mask |= NVREG_IRQ_OTHER; 4105 mask |= NVREG_IRQ_OTHER;
4104 } 4106 }
4105 } 4107 }
4106 /* disable_irq() contains synchronize_irq, thus no irq handler can run now */ 4108
4109 disable_irq_nosync_lockdep_irqsave(irq, &flags);
4110 synchronize_irq(irq);
4107 4111
4108 if (np->recover_error) { 4112 if (np->recover_error) {
4109 np->recover_error = 0; 4113 np->recover_error = 0;
@@ -4156,28 +4160,22 @@ static void nv_do_nic_poll(unsigned long data)
4156 nv_nic_irq_optimized(0, dev); 4160 nv_nic_irq_optimized(0, dev);
4157 else 4161 else
4158 nv_nic_irq(0, dev); 4162 nv_nic_irq(0, dev);
4159 if (np->msi_flags & NV_MSI_X_ENABLED)
4160 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
4161 else
4162 enable_irq_lockdep(np->pci_dev->irq);
4163 } else { 4163 } else {
4164 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { 4164 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
4165 np->nic_poll_irq &= ~NVREG_IRQ_RX_ALL; 4165 np->nic_poll_irq &= ~NVREG_IRQ_RX_ALL;
4166 nv_nic_irq_rx(0, dev); 4166 nv_nic_irq_rx(0, dev);
4167 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
4168 } 4167 }
4169 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) { 4168 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
4170 np->nic_poll_irq &= ~NVREG_IRQ_TX_ALL; 4169 np->nic_poll_irq &= ~NVREG_IRQ_TX_ALL;
4171 nv_nic_irq_tx(0, dev); 4170 nv_nic_irq_tx(0, dev);
4172 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
4173 } 4171 }
4174 if (np->nic_poll_irq & NVREG_IRQ_OTHER) { 4172 if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
4175 np->nic_poll_irq &= ~NVREG_IRQ_OTHER; 4173 np->nic_poll_irq &= ~NVREG_IRQ_OTHER;
4176 nv_nic_irq_other(0, dev); 4174 nv_nic_irq_other(0, dev);
4177 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
4178 } 4175 }
4179 } 4176 }
4180 4177
4178 enable_irq_lockdep_irqrestore(irq, &flags);
4181} 4179}
4182 4180
4183#ifdef CONFIG_NET_POLL_CONTROLLER 4181#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 66fd868152e5..b159ef8303cc 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -476,13 +476,12 @@ static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac)
476 mac[5] = tmp >> 8; 476 mac[5] = tmp >> 8;
477} 477}
478 478
479static void __lpc_eth_clock_enable(struct netdata_local *pldat, 479static void __lpc_eth_clock_enable(struct netdata_local *pldat, bool enable)
480 bool enable)
481{ 480{
482 if (enable) 481 if (enable)
483 clk_enable(pldat->clk); 482 clk_prepare_enable(pldat->clk);
484 else 483 else
485 clk_disable(pldat->clk); 484 clk_disable_unprepare(pldat->clk);
486} 485}
487 486
488static void __lpc_params_setup(struct netdata_local *pldat) 487static void __lpc_params_setup(struct netdata_local *pldat)
@@ -1494,7 +1493,7 @@ err_out_free_irq:
1494err_out_iounmap: 1493err_out_iounmap:
1495 iounmap(pldat->net_base); 1494 iounmap(pldat->net_base);
1496err_out_disable_clocks: 1495err_out_disable_clocks:
1497 clk_disable(pldat->clk); 1496 clk_disable_unprepare(pldat->clk);
1498 clk_put(pldat->clk); 1497 clk_put(pldat->clk);
1499err_out_free_dev: 1498err_out_free_dev:
1500 free_netdev(ndev); 1499 free_netdev(ndev);
@@ -1519,7 +1518,7 @@ static int lpc_eth_drv_remove(struct platform_device *pdev)
1519 iounmap(pldat->net_base); 1518 iounmap(pldat->net_base);
1520 mdiobus_unregister(pldat->mii_bus); 1519 mdiobus_unregister(pldat->mii_bus);
1521 mdiobus_free(pldat->mii_bus); 1520 mdiobus_free(pldat->mii_bus);
1522 clk_disable(pldat->clk); 1521 clk_disable_unprepare(pldat->clk);
1523 clk_put(pldat->clk); 1522 clk_put(pldat->clk);
1524 free_netdev(ndev); 1523 free_netdev(ndev);
1525 1524
@@ -1540,7 +1539,7 @@ static int lpc_eth_drv_suspend(struct platform_device *pdev,
1540 if (netif_running(ndev)) { 1539 if (netif_running(ndev)) {
1541 netif_device_detach(ndev); 1540 netif_device_detach(ndev);
1542 __lpc_eth_shutdown(pldat); 1541 __lpc_eth_shutdown(pldat);
1543 clk_disable(pldat->clk); 1542 clk_disable_unprepare(pldat->clk);
1544 1543
1545 /* 1544 /*
1546 * Reset again now clock is disable to be sure 1545 * Reset again now clock is disable to be sure
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 06bcc734fe8d..d6696cfa11d2 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -536,6 +536,7 @@ struct qlcnic_hardware_context {
536 u8 extend_lb_time; 536 u8 extend_lb_time;
537 u8 phys_port_id[ETH_ALEN]; 537 u8 phys_port_id[ETH_ALEN];
538 u8 lb_mode; 538 u8 lb_mode;
539 u8 vxlan_port_count;
539 u16 vxlan_port; 540 u16 vxlan_port;
540 struct device *hwmon_dev; 541 struct device *hwmon_dev;
541 u32 post_mode; 542 u32 post_mode;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 8b08b20e8b30..d4481454b5f8 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -483,11 +483,17 @@ static void qlcnic_add_vxlan_port(struct net_device *netdev,
483 /* Adapter supports only one VXLAN port. Use very first port 483 /* Adapter supports only one VXLAN port. Use very first port
484 * for enabling offload 484 * for enabling offload
485 */ 485 */
486 if (!qlcnic_encap_rx_offload(adapter) || ahw->vxlan_port) 486 if (!qlcnic_encap_rx_offload(adapter))
487 return; 487 return;
488 if (!ahw->vxlan_port_count) {
489 ahw->vxlan_port_count = 1;
490 ahw->vxlan_port = ntohs(port);
491 adapter->flags |= QLCNIC_ADD_VXLAN_PORT;
492 return;
493 }
494 if (ahw->vxlan_port == ntohs(port))
495 ahw->vxlan_port_count++;
488 496
489 ahw->vxlan_port = ntohs(port);
490 adapter->flags |= QLCNIC_ADD_VXLAN_PORT;
491} 497}
492 498
493static void qlcnic_del_vxlan_port(struct net_device *netdev, 499static void qlcnic_del_vxlan_port(struct net_device *netdev,
@@ -496,11 +502,13 @@ static void qlcnic_del_vxlan_port(struct net_device *netdev,
496 struct qlcnic_adapter *adapter = netdev_priv(netdev); 502 struct qlcnic_adapter *adapter = netdev_priv(netdev);
497 struct qlcnic_hardware_context *ahw = adapter->ahw; 503 struct qlcnic_hardware_context *ahw = adapter->ahw;
498 504
499 if (!qlcnic_encap_rx_offload(adapter) || !ahw->vxlan_port || 505 if (!qlcnic_encap_rx_offload(adapter) || !ahw->vxlan_port_count ||
500 (ahw->vxlan_port != ntohs(port))) 506 (ahw->vxlan_port != ntohs(port)))
501 return; 507 return;
502 508
503 adapter->flags |= QLCNIC_DEL_VXLAN_PORT; 509 ahw->vxlan_port_count--;
510 if (!ahw->vxlan_port_count)
511 adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
504} 512}
505 513
506static netdev_features_t qlcnic_features_check(struct sk_buff *skb, 514static netdev_features_t qlcnic_features_check(struct sk_buff *skb,
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index d79e33b3c191..686334f4588d 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -157,6 +157,7 @@ enum {
157 NWayAdvert = 0x66, /* MII ADVERTISE */ 157 NWayAdvert = 0x66, /* MII ADVERTISE */
158 NWayLPAR = 0x68, /* MII LPA */ 158 NWayLPAR = 0x68, /* MII LPA */
159 NWayExpansion = 0x6A, /* MII Expansion */ 159 NWayExpansion = 0x6A, /* MII Expansion */
160 TxDmaOkLowDesc = 0x82, /* Low 16 bit address of a Tx descriptor. */
160 Config5 = 0xD8, /* Config5 */ 161 Config5 = 0xD8, /* Config5 */
161 TxPoll = 0xD9, /* Tell chip to check Tx descriptors for work */ 162 TxPoll = 0xD9, /* Tell chip to check Tx descriptors for work */
162 RxMaxSize = 0xDA, /* Max size of an Rx packet (8169 only) */ 163 RxMaxSize = 0xDA, /* Max size of an Rx packet (8169 only) */
@@ -341,6 +342,7 @@ struct cp_private {
341 unsigned tx_tail; 342 unsigned tx_tail;
342 struct cp_desc *tx_ring; 343 struct cp_desc *tx_ring;
343 struct sk_buff *tx_skb[CP_TX_RING_SIZE]; 344 struct sk_buff *tx_skb[CP_TX_RING_SIZE];
345 u32 tx_opts[CP_TX_RING_SIZE];
344 346
345 unsigned rx_buf_sz; 347 unsigned rx_buf_sz;
346 unsigned wol_enabled : 1; /* Is Wake-on-LAN enabled? */ 348 unsigned wol_enabled : 1; /* Is Wake-on-LAN enabled? */
@@ -665,7 +667,7 @@ static void cp_tx (struct cp_private *cp)
665 BUG_ON(!skb); 667 BUG_ON(!skb);
666 668
667 dma_unmap_single(&cp->pdev->dev, le64_to_cpu(txd->addr), 669 dma_unmap_single(&cp->pdev->dev, le64_to_cpu(txd->addr),
668 le32_to_cpu(txd->opts1) & 0xffff, 670 cp->tx_opts[tx_tail] & 0xffff,
669 PCI_DMA_TODEVICE); 671 PCI_DMA_TODEVICE);
670 672
671 if (status & LastFrag) { 673 if (status & LastFrag) {
@@ -733,7 +735,7 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
733{ 735{
734 struct cp_private *cp = netdev_priv(dev); 736 struct cp_private *cp = netdev_priv(dev);
735 unsigned entry; 737 unsigned entry;
736 u32 eor, flags; 738 u32 eor, opts1;
737 unsigned long intr_flags; 739 unsigned long intr_flags;
738 __le32 opts2; 740 __le32 opts2;
739 int mss = 0; 741 int mss = 0;
@@ -753,6 +755,21 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
753 mss = skb_shinfo(skb)->gso_size; 755 mss = skb_shinfo(skb)->gso_size;
754 756
755 opts2 = cpu_to_le32(cp_tx_vlan_tag(skb)); 757 opts2 = cpu_to_le32(cp_tx_vlan_tag(skb));
758 opts1 = DescOwn;
759 if (mss)
760 opts1 |= LargeSend | ((mss & MSSMask) << MSSShift);
761 else if (skb->ip_summed == CHECKSUM_PARTIAL) {
762 const struct iphdr *ip = ip_hdr(skb);
763 if (ip->protocol == IPPROTO_TCP)
764 opts1 |= IPCS | TCPCS;
765 else if (ip->protocol == IPPROTO_UDP)
766 opts1 |= IPCS | UDPCS;
767 else {
768 WARN_ONCE(1,
769 "Net bug: asked to checksum invalid Legacy IP packet\n");
770 goto out_dma_error;
771 }
772 }
756 773
757 if (skb_shinfo(skb)->nr_frags == 0) { 774 if (skb_shinfo(skb)->nr_frags == 0) {
758 struct cp_desc *txd = &cp->tx_ring[entry]; 775 struct cp_desc *txd = &cp->tx_ring[entry];
@@ -768,31 +785,20 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
768 txd->addr = cpu_to_le64(mapping); 785 txd->addr = cpu_to_le64(mapping);
769 wmb(); 786 wmb();
770 787
771 flags = eor | len | DescOwn | FirstFrag | LastFrag; 788 opts1 |= eor | len | FirstFrag | LastFrag;
772
773 if (mss)
774 flags |= LargeSend | ((mss & MSSMask) << MSSShift);
775 else if (skb->ip_summed == CHECKSUM_PARTIAL) {
776 const struct iphdr *ip = ip_hdr(skb);
777 if (ip->protocol == IPPROTO_TCP)
778 flags |= IPCS | TCPCS;
779 else if (ip->protocol == IPPROTO_UDP)
780 flags |= IPCS | UDPCS;
781 else
782 WARN_ON(1); /* we need a WARN() */
783 }
784 789
785 txd->opts1 = cpu_to_le32(flags); 790 txd->opts1 = cpu_to_le32(opts1);
786 wmb(); 791 wmb();
787 792
788 cp->tx_skb[entry] = skb; 793 cp->tx_skb[entry] = skb;
789 entry = NEXT_TX(entry); 794 cp->tx_opts[entry] = opts1;
795 netif_dbg(cp, tx_queued, cp->dev, "tx queued, slot %d, skblen %d\n",
796 entry, skb->len);
790 } else { 797 } else {
791 struct cp_desc *txd; 798 struct cp_desc *txd;
792 u32 first_len, first_eor; 799 u32 first_len, first_eor, ctrl;
793 dma_addr_t first_mapping; 800 dma_addr_t first_mapping;
794 int frag, first_entry = entry; 801 int frag, first_entry = entry;
795 const struct iphdr *ip = ip_hdr(skb);
796 802
797 /* We must give this initial chunk to the device last. 803 /* We must give this initial chunk to the device last.
798 * Otherwise we could race with the device. 804 * Otherwise we could race with the device.
@@ -805,14 +811,14 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
805 goto out_dma_error; 811 goto out_dma_error;
806 812
807 cp->tx_skb[entry] = skb; 813 cp->tx_skb[entry] = skb;
808 entry = NEXT_TX(entry);
809 814
810 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { 815 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) {
811 const skb_frag_t *this_frag = &skb_shinfo(skb)->frags[frag]; 816 const skb_frag_t *this_frag = &skb_shinfo(skb)->frags[frag];
812 u32 len; 817 u32 len;
813 u32 ctrl;
814 dma_addr_t mapping; 818 dma_addr_t mapping;
815 819
820 entry = NEXT_TX(entry);
821
816 len = skb_frag_size(this_frag); 822 len = skb_frag_size(this_frag);
817 mapping = dma_map_single(&cp->pdev->dev, 823 mapping = dma_map_single(&cp->pdev->dev,
818 skb_frag_address(this_frag), 824 skb_frag_address(this_frag),
@@ -824,19 +830,7 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
824 830
825 eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0; 831 eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
826 832
827 ctrl = eor | len | DescOwn; 833 ctrl = opts1 | eor | len;
828
829 if (mss)
830 ctrl |= LargeSend |
831 ((mss & MSSMask) << MSSShift);
832 else if (skb->ip_summed == CHECKSUM_PARTIAL) {
833 if (ip->protocol == IPPROTO_TCP)
834 ctrl |= IPCS | TCPCS;
835 else if (ip->protocol == IPPROTO_UDP)
836 ctrl |= IPCS | UDPCS;
837 else
838 BUG();
839 }
840 834
841 if (frag == skb_shinfo(skb)->nr_frags - 1) 835 if (frag == skb_shinfo(skb)->nr_frags - 1)
842 ctrl |= LastFrag; 836 ctrl |= LastFrag;
@@ -849,8 +843,8 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
849 txd->opts1 = cpu_to_le32(ctrl); 843 txd->opts1 = cpu_to_le32(ctrl);
850 wmb(); 844 wmb();
851 845
846 cp->tx_opts[entry] = ctrl;
852 cp->tx_skb[entry] = skb; 847 cp->tx_skb[entry] = skb;
853 entry = NEXT_TX(entry);
854 } 848 }
855 849
856 txd = &cp->tx_ring[first_entry]; 850 txd = &cp->tx_ring[first_entry];
@@ -858,27 +852,17 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
858 txd->addr = cpu_to_le64(first_mapping); 852 txd->addr = cpu_to_le64(first_mapping);
859 wmb(); 853 wmb();
860 854
861 if (skb->ip_summed == CHECKSUM_PARTIAL) { 855 ctrl = opts1 | first_eor | first_len | FirstFrag;
862 if (ip->protocol == IPPROTO_TCP) 856 txd->opts1 = cpu_to_le32(ctrl);
863 txd->opts1 = cpu_to_le32(first_eor | first_len |
864 FirstFrag | DescOwn |
865 IPCS | TCPCS);
866 else if (ip->protocol == IPPROTO_UDP)
867 txd->opts1 = cpu_to_le32(first_eor | first_len |
868 FirstFrag | DescOwn |
869 IPCS | UDPCS);
870 else
871 BUG();
872 } else
873 txd->opts1 = cpu_to_le32(first_eor | first_len |
874 FirstFrag | DescOwn);
875 wmb(); 857 wmb();
858
859 cp->tx_opts[first_entry] = ctrl;
860 netif_dbg(cp, tx_queued, cp->dev, "tx queued, slots %d-%d, skblen %d\n",
861 first_entry, entry, skb->len);
876 } 862 }
877 cp->tx_head = entry; 863 cp->tx_head = NEXT_TX(entry);
878 864
879 netdev_sent_queue(dev, skb->len); 865 netdev_sent_queue(dev, skb->len);
880 netif_dbg(cp, tx_queued, cp->dev, "tx queued, slot %d, skblen %d\n",
881 entry, skb->len);
882 if (TX_BUFFS_AVAIL(cp) <= (MAX_SKB_FRAGS + 1)) 866 if (TX_BUFFS_AVAIL(cp) <= (MAX_SKB_FRAGS + 1))
883 netif_stop_queue(dev); 867 netif_stop_queue(dev);
884 868
@@ -1115,6 +1099,7 @@ static int cp_init_rings (struct cp_private *cp)
1115{ 1099{
1116 memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE); 1100 memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE);
1117 cp->tx_ring[CP_TX_RING_SIZE - 1].opts1 = cpu_to_le32(RingEnd); 1101 cp->tx_ring[CP_TX_RING_SIZE - 1].opts1 = cpu_to_le32(RingEnd);
1102 memset(cp->tx_opts, 0, sizeof(cp->tx_opts));
1118 1103
1119 cp_init_rings_index(cp); 1104 cp_init_rings_index(cp);
1120 1105
@@ -1151,7 +1136,7 @@ static void cp_clean_rings (struct cp_private *cp)
1151 desc = cp->rx_ring + i; 1136 desc = cp->rx_ring + i;
1152 dma_unmap_single(&cp->pdev->dev,le64_to_cpu(desc->addr), 1137 dma_unmap_single(&cp->pdev->dev,le64_to_cpu(desc->addr),
1153 cp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1138 cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1154 dev_kfree_skb(cp->rx_skb[i]); 1139 dev_kfree_skb_any(cp->rx_skb[i]);
1155 } 1140 }
1156 } 1141 }
1157 1142
@@ -1164,7 +1149,7 @@ static void cp_clean_rings (struct cp_private *cp)
1164 le32_to_cpu(desc->opts1) & 0xffff, 1149 le32_to_cpu(desc->opts1) & 0xffff,
1165 PCI_DMA_TODEVICE); 1150 PCI_DMA_TODEVICE);
1166 if (le32_to_cpu(desc->opts1) & LastFrag) 1151 if (le32_to_cpu(desc->opts1) & LastFrag)
1167 dev_kfree_skb(skb); 1152 dev_kfree_skb_any(skb);
1168 cp->dev->stats.tx_dropped++; 1153 cp->dev->stats.tx_dropped++;
1169 } 1154 }
1170 } 1155 }
@@ -1172,6 +1157,7 @@ static void cp_clean_rings (struct cp_private *cp)
1172 1157
1173 memset(cp->rx_ring, 0, sizeof(struct cp_desc) * CP_RX_RING_SIZE); 1158 memset(cp->rx_ring, 0, sizeof(struct cp_desc) * CP_RX_RING_SIZE);
1174 memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE); 1159 memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE);
1160 memset(cp->tx_opts, 0, sizeof(cp->tx_opts));
1175 1161
1176 memset(cp->rx_skb, 0, sizeof(struct sk_buff *) * CP_RX_RING_SIZE); 1162 memset(cp->rx_skb, 0, sizeof(struct sk_buff *) * CP_RX_RING_SIZE);
1177 memset(cp->tx_skb, 0, sizeof(struct sk_buff *) * CP_TX_RING_SIZE); 1163 memset(cp->tx_skb, 0, sizeof(struct sk_buff *) * CP_TX_RING_SIZE);
@@ -1249,7 +1235,7 @@ static void cp_tx_timeout(struct net_device *dev)
1249{ 1235{
1250 struct cp_private *cp = netdev_priv(dev); 1236 struct cp_private *cp = netdev_priv(dev);
1251 unsigned long flags; 1237 unsigned long flags;
1252 int rc; 1238 int rc, i;
1253 1239
1254 netdev_warn(dev, "Transmit timeout, status %2x %4x %4x %4x\n", 1240 netdev_warn(dev, "Transmit timeout, status %2x %4x %4x %4x\n",
1255 cpr8(Cmd), cpr16(CpCmd), 1241 cpr8(Cmd), cpr16(CpCmd),
@@ -1257,13 +1243,26 @@ static void cp_tx_timeout(struct net_device *dev)
1257 1243
1258 spin_lock_irqsave(&cp->lock, flags); 1244 spin_lock_irqsave(&cp->lock, flags);
1259 1245
1246 netif_dbg(cp, tx_err, cp->dev, "TX ring head %d tail %d desc %x\n",
1247 cp->tx_head, cp->tx_tail, cpr16(TxDmaOkLowDesc));
1248 for (i = 0; i < CP_TX_RING_SIZE; i++) {
1249 netif_dbg(cp, tx_err, cp->dev,
1250 "TX slot %d @%p: %08x (%08x) %08x %llx %p\n",
1251 i, &cp->tx_ring[i], le32_to_cpu(cp->tx_ring[i].opts1),
1252 cp->tx_opts[i], le32_to_cpu(cp->tx_ring[i].opts2),
1253 le64_to_cpu(cp->tx_ring[i].addr),
1254 cp->tx_skb[i]);
1255 }
1256
1260 cp_stop_hw(cp); 1257 cp_stop_hw(cp);
1261 cp_clean_rings(cp); 1258 cp_clean_rings(cp);
1262 rc = cp_init_rings(cp); 1259 rc = cp_init_rings(cp);
1263 cp_start_hw(cp); 1260 cp_start_hw(cp);
1264 cp_enable_irq(cp); 1261 __cp_set_rx_mode(dev);
1262 cpw16_f(IntrMask, cp_norx_intr_mask);
1265 1263
1266 netif_wake_queue(dev); 1264 netif_wake_queue(dev);
1265 napi_schedule_irqoff(&cp->napi);
1267 1266
1268 spin_unlock_irqrestore(&cp->lock, flags); 1267 spin_unlock_irqrestore(&cp->lock, flags);
1269} 1268}
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 2b32e0c5a0b4..b4f21232019a 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -6081,7 +6081,7 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
6081{ 6081{
6082 void __iomem *ioaddr = tp->mmio_addr; 6082 void __iomem *ioaddr = tp->mmio_addr;
6083 struct pci_dev *pdev = tp->pci_dev; 6083 struct pci_dev *pdev = tp->pci_dev;
6084 u16 rg_saw_cnt; 6084 int rg_saw_cnt;
6085 u32 data; 6085 u32 data;
6086 static const struct ephy_info e_info_8168h_1[] = { 6086 static const struct ephy_info e_info_8168h_1[] = {
6087 { 0x1e, 0x0800, 0x0001 }, 6087 { 0x1e, 0x0800, 0x0001 },
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 257ea713b4c1..a484d8beb855 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1127,7 +1127,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
1127 struct sh_eth_txdesc *txdesc = NULL; 1127 struct sh_eth_txdesc *txdesc = NULL;
1128 int rx_ringsize = sizeof(*rxdesc) * mdp->num_rx_ring; 1128 int rx_ringsize = sizeof(*rxdesc) * mdp->num_rx_ring;
1129 int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring; 1129 int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring;
1130 int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN - 1; 1130 int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1;
1131 dma_addr_t dma_addr; 1131 dma_addr_t dma_addr;
1132 1132
1133 mdp->cur_rx = 0; 1133 mdp->cur_rx = 0;
@@ -1148,8 +1148,8 @@ static void sh_eth_ring_format(struct net_device *ndev)
1148 1148
1149 /* RX descriptor */ 1149 /* RX descriptor */
1150 rxdesc = &mdp->rx_ring[i]; 1150 rxdesc = &mdp->rx_ring[i];
1151 /* The size of the buffer is a multiple of 16 bytes. */ 1151 /* The size of the buffer is a multiple of 32 bytes. */
1152 rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); 1152 rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32);
1153 dma_addr = dma_map_single(&ndev->dev, skb->data, 1153 dma_addr = dma_map_single(&ndev->dev, skb->data,
1154 rxdesc->buffer_length, 1154 rxdesc->buffer_length,
1155 DMA_FROM_DEVICE); 1155 DMA_FROM_DEVICE);
@@ -1450,7 +1450,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
1450 struct sk_buff *skb; 1450 struct sk_buff *skb;
1451 u16 pkt_len = 0; 1451 u16 pkt_len = 0;
1452 u32 desc_status; 1452 u32 desc_status;
1453 int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN - 1; 1453 int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1;
1454 dma_addr_t dma_addr; 1454 dma_addr_t dma_addr;
1455 1455
1456 boguscnt = min(boguscnt, *quota); 1456 boguscnt = min(boguscnt, *quota);
@@ -1506,7 +1506,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
1506 if (mdp->cd->rpadir) 1506 if (mdp->cd->rpadir)
1507 skb_reserve(skb, NET_IP_ALIGN); 1507 skb_reserve(skb, NET_IP_ALIGN);
1508 dma_unmap_single(&ndev->dev, rxdesc->addr, 1508 dma_unmap_single(&ndev->dev, rxdesc->addr,
1509 ALIGN(mdp->rx_buf_sz, 16), 1509 ALIGN(mdp->rx_buf_sz, 32),
1510 DMA_FROM_DEVICE); 1510 DMA_FROM_DEVICE);
1511 skb_put(skb, pkt_len); 1511 skb_put(skb, pkt_len);
1512 skb->protocol = eth_type_trans(skb, ndev); 1512 skb->protocol = eth_type_trans(skb, ndev);
@@ -1524,8 +1524,8 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
1524 for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) { 1524 for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) {
1525 entry = mdp->dirty_rx % mdp->num_rx_ring; 1525 entry = mdp->dirty_rx % mdp->num_rx_ring;
1526 rxdesc = &mdp->rx_ring[entry]; 1526 rxdesc = &mdp->rx_ring[entry];
1527 /* The size of the buffer is 16 byte boundary. */ 1527 /* The size of the buffer is 32 byte boundary. */
1528 rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); 1528 rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32);
1529 1529
1530 if (mdp->rx_skbuff[entry] == NULL) { 1530 if (mdp->rx_skbuff[entry] == NULL) {
1531 skb = netdev_alloc_skb(ndev, skbuff_size); 1531 skb = netdev_alloc_skb(ndev, skbuff_size);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b735fa22ac95..ebf6abc4853f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -161,11 +161,16 @@ int stmmac_mdio_reset(struct mii_bus *bus)
161 161
162 if (!gpio_request(reset_gpio, "mdio-reset")) { 162 if (!gpio_request(reset_gpio, "mdio-reset")) {
163 gpio_direction_output(reset_gpio, active_low ? 1 : 0); 163 gpio_direction_output(reset_gpio, active_low ? 1 : 0);
164 udelay(data->delays[0]); 164 if (data->delays[0])
165 msleep(DIV_ROUND_UP(data->delays[0], 1000));
166
165 gpio_set_value(reset_gpio, active_low ? 0 : 1); 167 gpio_set_value(reset_gpio, active_low ? 0 : 1);
166 udelay(data->delays[1]); 168 if (data->delays[1])
169 msleep(DIV_ROUND_UP(data->delays[1], 1000));
170
167 gpio_set_value(reset_gpio, active_low ? 1 : 0); 171 gpio_set_value(reset_gpio, active_low ? 1 : 0);
168 udelay(data->delays[2]); 172 if (data->delays[2])
173 msleep(DIV_ROUND_UP(data->delays[2], 1000));
169 } 174 }
170 } 175 }
171#endif 176#endif
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index 53fe200e0b79..cc106d892e29 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -1756,7 +1756,8 @@ static const struct net_device_ops vnet_ops = {
1756#endif 1756#endif
1757}; 1757};
1758 1758
1759static struct vnet *vnet_new(const u64 *local_mac) 1759static struct vnet *vnet_new(const u64 *local_mac,
1760 struct vio_dev *vdev)
1760{ 1761{
1761 struct net_device *dev; 1762 struct net_device *dev;
1762 struct vnet *vp; 1763 struct vnet *vp;
@@ -1790,6 +1791,8 @@ static struct vnet *vnet_new(const u64 *local_mac)
1790 NETIF_F_HW_CSUM | NETIF_F_SG; 1791 NETIF_F_HW_CSUM | NETIF_F_SG;
1791 dev->features = dev->hw_features; 1792 dev->features = dev->hw_features;
1792 1793
1794 SET_NETDEV_DEV(dev, &vdev->dev);
1795
1793 err = register_netdev(dev); 1796 err = register_netdev(dev);
1794 if (err) { 1797 if (err) {
1795 pr_err("Cannot register net device, aborting\n"); 1798 pr_err("Cannot register net device, aborting\n");
@@ -1808,7 +1811,8 @@ err_out_free_dev:
1808 return ERR_PTR(err); 1811 return ERR_PTR(err);
1809} 1812}
1810 1813
1811static struct vnet *vnet_find_or_create(const u64 *local_mac) 1814static struct vnet *vnet_find_or_create(const u64 *local_mac,
1815 struct vio_dev *vdev)
1812{ 1816{
1813 struct vnet *iter, *vp; 1817 struct vnet *iter, *vp;
1814 1818
@@ -1821,7 +1825,7 @@ static struct vnet *vnet_find_or_create(const u64 *local_mac)
1821 } 1825 }
1822 } 1826 }
1823 if (!vp) 1827 if (!vp)
1824 vp = vnet_new(local_mac); 1828 vp = vnet_new(local_mac, vdev);
1825 mutex_unlock(&vnet_list_mutex); 1829 mutex_unlock(&vnet_list_mutex);
1826 1830
1827 return vp; 1831 return vp;
@@ -1848,7 +1852,8 @@ static void vnet_cleanup(void)
1848static const char *local_mac_prop = "local-mac-address"; 1852static const char *local_mac_prop = "local-mac-address";
1849 1853
1850static struct vnet *vnet_find_parent(struct mdesc_handle *hp, 1854static struct vnet *vnet_find_parent(struct mdesc_handle *hp,
1851 u64 port_node) 1855 u64 port_node,
1856 struct vio_dev *vdev)
1852{ 1857{
1853 const u64 *local_mac = NULL; 1858 const u64 *local_mac = NULL;
1854 u64 a; 1859 u64 a;
@@ -1869,7 +1874,7 @@ static struct vnet *vnet_find_parent(struct mdesc_handle *hp,
1869 if (!local_mac) 1874 if (!local_mac)
1870 return ERR_PTR(-ENODEV); 1875 return ERR_PTR(-ENODEV);
1871 1876
1872 return vnet_find_or_create(local_mac); 1877 return vnet_find_or_create(local_mac, vdev);
1873} 1878}
1874 1879
1875static struct ldc_channel_config vnet_ldc_cfg = { 1880static struct ldc_channel_config vnet_ldc_cfg = {
@@ -1923,7 +1928,7 @@ static int vnet_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1923 1928
1924 hp = mdesc_grab(); 1929 hp = mdesc_grab();
1925 1930
1926 vp = vnet_find_parent(hp, vdev->mp); 1931 vp = vnet_find_parent(hp, vdev->mp, vdev);
1927 if (IS_ERR(vp)) { 1932 if (IS_ERR(vp)) {
1928 pr_err("Cannot find port parent vnet\n"); 1933 pr_err("Cannot find port parent vnet\n");
1929 err = PTR_ERR(vp); 1934 err = PTR_ERR(vp);
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 8fc90f1c872c..874fb297e96c 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -30,6 +30,7 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/pm_runtime.h> 31#include <linux/pm_runtime.h>
32#include <linux/of.h> 32#include <linux/of.h>
33#include <linux/of_mdio.h>
33#include <linux/of_net.h> 34#include <linux/of_net.h>
34#include <linux/of_device.h> 35#include <linux/of_device.h>
35#include <linux/if_vlan.h> 36#include <linux/if_vlan.h>
@@ -365,6 +366,7 @@ struct cpsw_priv {
365 spinlock_t lock; 366 spinlock_t lock;
366 struct platform_device *pdev; 367 struct platform_device *pdev;
367 struct net_device *ndev; 368 struct net_device *ndev;
369 struct device_node *phy_node;
368 struct napi_struct napi_rx; 370 struct napi_struct napi_rx;
369 struct napi_struct napi_tx; 371 struct napi_struct napi_tx;
370 struct device *dev; 372 struct device *dev;
@@ -1145,7 +1147,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
1145 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1147 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
1146 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); 1148 1 << slave_port, 0, 0, ALE_MCAST_FWD_2);
1147 1149
1148 slave->phy = phy_connect(priv->ndev, slave->data->phy_id, 1150 if (priv->phy_node)
1151 slave->phy = of_phy_connect(priv->ndev, priv->phy_node,
1152 &cpsw_adjust_link, 0, slave->data->phy_if);
1153 else
1154 slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
1149 &cpsw_adjust_link, slave->data->phy_if); 1155 &cpsw_adjust_link, slave->data->phy_if);
1150 if (IS_ERR(slave->phy)) { 1156 if (IS_ERR(slave->phy)) {
1151 dev_err(priv->dev, "phy %s not found on slave %d\n", 1157 dev_err(priv->dev, "phy %s not found on slave %d\n",
@@ -1934,11 +1940,12 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
1934 slave->port_vlan = data->dual_emac_res_vlan; 1940 slave->port_vlan = data->dual_emac_res_vlan;
1935} 1941}
1936 1942
1937static int cpsw_probe_dt(struct cpsw_platform_data *data, 1943static int cpsw_probe_dt(struct cpsw_priv *priv,
1938 struct platform_device *pdev) 1944 struct platform_device *pdev)
1939{ 1945{
1940 struct device_node *node = pdev->dev.of_node; 1946 struct device_node *node = pdev->dev.of_node;
1941 struct device_node *slave_node; 1947 struct device_node *slave_node;
1948 struct cpsw_platform_data *data = &priv->data;
1942 int i = 0, ret; 1949 int i = 0, ret;
1943 u32 prop; 1950 u32 prop;
1944 1951
@@ -2029,6 +2036,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2029 if (strcmp(slave_node->name, "slave")) 2036 if (strcmp(slave_node->name, "slave"))
2030 continue; 2037 continue;
2031 2038
2039 priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
2032 parp = of_get_property(slave_node, "phy_id", &lenp); 2040 parp = of_get_property(slave_node, "phy_id", &lenp);
2033 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { 2041 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
2034 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i); 2042 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
@@ -2044,7 +2052,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2044 } 2052 }
2045 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 2053 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
2046 PHY_ID_FMT, mdio->name, phyid); 2054 PHY_ID_FMT, mdio->name, phyid);
2047
2048 slave_data->phy_if = of_get_phy_mode(slave_node); 2055 slave_data->phy_if = of_get_phy_mode(slave_node);
2049 if (slave_data->phy_if < 0) { 2056 if (slave_data->phy_if < 0) {
2050 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n", 2057 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
@@ -2240,7 +2247,7 @@ static int cpsw_probe(struct platform_device *pdev)
2240 /* Select default pin state */ 2247 /* Select default pin state */
2241 pinctrl_pm_select_default_state(&pdev->dev); 2248 pinctrl_pm_select_default_state(&pdev->dev);
2242 2249
2243 if (cpsw_probe_dt(&priv->data, pdev)) { 2250 if (cpsw_probe_dt(priv, pdev)) {
2244 dev_err(&pdev->dev, "cpsw: platform data missing\n"); 2251 dev_err(&pdev->dev, "cpsw: platform data missing\n");
2245 ret = -ENODEV; 2252 ret = -ENODEV;
2246 goto clean_runtime_disable_ret; 2253 goto clean_runtime_disable_ret;
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 1a5aca55ea9f..9f9832f0dea9 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -291,13 +291,6 @@ static int netcp_module_probe(struct netcp_device *netcp_device,
291 interface_list) { 291 interface_list) {
292 struct netcp_intf_modpriv *intf_modpriv; 292 struct netcp_intf_modpriv *intf_modpriv;
293 293
294 /* If interface not registered then register now */
295 if (!netcp_intf->netdev_registered)
296 ret = netcp_register_interface(netcp_intf);
297
298 if (ret)
299 return -ENODEV;
300
301 intf_modpriv = devm_kzalloc(dev, sizeof(*intf_modpriv), 294 intf_modpriv = devm_kzalloc(dev, sizeof(*intf_modpriv),
302 GFP_KERNEL); 295 GFP_KERNEL);
303 if (!intf_modpriv) 296 if (!intf_modpriv)
@@ -306,6 +299,11 @@ static int netcp_module_probe(struct netcp_device *netcp_device,
306 interface = of_parse_phandle(netcp_intf->node_interface, 299 interface = of_parse_phandle(netcp_intf->node_interface,
307 module->name, 0); 300 module->name, 0);
308 301
302 if (!interface) {
303 devm_kfree(dev, intf_modpriv);
304 continue;
305 }
306
309 intf_modpriv->netcp_priv = netcp_intf; 307 intf_modpriv->netcp_priv = netcp_intf;
310 intf_modpriv->netcp_module = module; 308 intf_modpriv->netcp_module = module;
311 list_add_tail(&intf_modpriv->intf_list, 309 list_add_tail(&intf_modpriv->intf_list,
@@ -323,6 +321,18 @@ static int netcp_module_probe(struct netcp_device *netcp_device,
323 continue; 321 continue;
324 } 322 }
325 } 323 }
324
325 /* Now register the interface with netdev */
326 list_for_each_entry(netcp_intf,
327 &netcp_device->interface_head,
328 interface_list) {
329 /* If interface not registered then register now */
330 if (!netcp_intf->netdev_registered) {
331 ret = netcp_register_interface(netcp_intf);
332 if (ret)
333 return -ENODEV;
334 }
335 }
326 return 0; 336 return 0;
327} 337}
328 338
@@ -357,7 +367,6 @@ int netcp_register_module(struct netcp_module *module)
357 if (ret < 0) 367 if (ret < 0)
358 goto fail; 368 goto fail;
359 } 369 }
360
361 mutex_unlock(&netcp_modules_lock); 370 mutex_unlock(&netcp_modules_lock);
362 return 0; 371 return 0;
363 372
@@ -796,7 +805,7 @@ static void netcp_rxpool_free(struct netcp_intf *netcp)
796 netcp->rx_pool = NULL; 805 netcp->rx_pool = NULL;
797} 806}
798 807
799static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) 808static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
800{ 809{
801 struct knav_dma_desc *hwdesc; 810 struct knav_dma_desc *hwdesc;
802 unsigned int buf_len, dma_sz; 811 unsigned int buf_len, dma_sz;
@@ -810,7 +819,7 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
810 hwdesc = knav_pool_desc_get(netcp->rx_pool); 819 hwdesc = knav_pool_desc_get(netcp->rx_pool);
811 if (IS_ERR_OR_NULL(hwdesc)) { 820 if (IS_ERR_OR_NULL(hwdesc)) {
812 dev_dbg(netcp->ndev_dev, "out of rx pool desc\n"); 821 dev_dbg(netcp->ndev_dev, "out of rx pool desc\n");
813 return; 822 return -ENOMEM;
814 } 823 }
815 824
816 if (likely(fdq == 0)) { 825 if (likely(fdq == 0)) {
@@ -862,25 +871,26 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
862 knav_pool_desc_map(netcp->rx_pool, hwdesc, sizeof(*hwdesc), &dma, 871 knav_pool_desc_map(netcp->rx_pool, hwdesc, sizeof(*hwdesc), &dma,
863 &dma_sz); 872 &dma_sz);
864 knav_queue_push(netcp->rx_fdq[fdq], dma, sizeof(*hwdesc), 0); 873 knav_queue_push(netcp->rx_fdq[fdq], dma, sizeof(*hwdesc), 0);
865 return; 874 return 0;
866 875
867fail: 876fail:
868 knav_pool_desc_put(netcp->rx_pool, hwdesc); 877 knav_pool_desc_put(netcp->rx_pool, hwdesc);
878 return -ENOMEM;
869} 879}
870 880
871/* Refill Rx FDQ with descriptors & attached buffers */ 881/* Refill Rx FDQ with descriptors & attached buffers */
872static void netcp_rxpool_refill(struct netcp_intf *netcp) 882static void netcp_rxpool_refill(struct netcp_intf *netcp)
873{ 883{
874 u32 fdq_deficit[KNAV_DMA_FDQ_PER_CHAN] = {0}; 884 u32 fdq_deficit[KNAV_DMA_FDQ_PER_CHAN] = {0};
875 int i; 885 int i, ret = 0;
876 886
877 /* Calculate the FDQ deficit and refill */ 887 /* Calculate the FDQ deficit and refill */
878 for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && netcp->rx_fdq[i]; i++) { 888 for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && netcp->rx_fdq[i]; i++) {
879 fdq_deficit[i] = netcp->rx_queue_depths[i] - 889 fdq_deficit[i] = netcp->rx_queue_depths[i] -
880 knav_queue_get_count(netcp->rx_fdq[i]); 890 knav_queue_get_count(netcp->rx_fdq[i]);
881 891
882 while (fdq_deficit[i]--) 892 while (fdq_deficit[i]-- && !ret)
883 netcp_allocate_rx_buf(netcp, i); 893 ret = netcp_allocate_rx_buf(netcp, i);
884 } /* end for fdqs */ 894 } /* end for fdqs */
885} 895}
886 896
@@ -893,12 +903,12 @@ static int netcp_rx_poll(struct napi_struct *napi, int budget)
893 903
894 packets = netcp_process_rx_packets(netcp, budget); 904 packets = netcp_process_rx_packets(netcp, budget);
895 905
906 netcp_rxpool_refill(netcp);
896 if (packets < budget) { 907 if (packets < budget) {
897 napi_complete(&netcp->rx_napi); 908 napi_complete(&netcp->rx_napi);
898 knav_queue_enable_notify(netcp->rx_queue); 909 knav_queue_enable_notify(netcp->rx_queue);
899 } 910 }
900 911
901 netcp_rxpool_refill(netcp);
902 return packets; 912 return packets;
903} 913}
904 914
@@ -1384,7 +1394,6 @@ static void netcp_addr_sweep_del(struct netcp_intf *netcp)
1384 continue; 1394 continue;
1385 dev_dbg(netcp->ndev_dev, "deleting address %pM, type %x\n", 1395 dev_dbg(netcp->ndev_dev, "deleting address %pM, type %x\n",
1386 naddr->addr, naddr->type); 1396 naddr->addr, naddr->type);
1387 mutex_lock(&netcp_modules_lock);
1388 for_each_module(netcp, priv) { 1397 for_each_module(netcp, priv) {
1389 module = priv->netcp_module; 1398 module = priv->netcp_module;
1390 if (!module->del_addr) 1399 if (!module->del_addr)
@@ -1393,7 +1402,6 @@ static void netcp_addr_sweep_del(struct netcp_intf *netcp)
1393 naddr); 1402 naddr);
1394 WARN_ON(error); 1403 WARN_ON(error);
1395 } 1404 }
1396 mutex_unlock(&netcp_modules_lock);
1397 netcp_addr_del(netcp, naddr); 1405 netcp_addr_del(netcp, naddr);
1398 } 1406 }
1399} 1407}
@@ -1410,7 +1418,7 @@ static void netcp_addr_sweep_add(struct netcp_intf *netcp)
1410 continue; 1418 continue;
1411 dev_dbg(netcp->ndev_dev, "adding address %pM, type %x\n", 1419 dev_dbg(netcp->ndev_dev, "adding address %pM, type %x\n",
1412 naddr->addr, naddr->type); 1420 naddr->addr, naddr->type);
1413 mutex_lock(&netcp_modules_lock); 1421
1414 for_each_module(netcp, priv) { 1422 for_each_module(netcp, priv) {
1415 module = priv->netcp_module; 1423 module = priv->netcp_module;
1416 if (!module->add_addr) 1424 if (!module->add_addr)
@@ -1418,7 +1426,6 @@ static void netcp_addr_sweep_add(struct netcp_intf *netcp)
1418 error = module->add_addr(priv->module_priv, naddr); 1426 error = module->add_addr(priv->module_priv, naddr);
1419 WARN_ON(error); 1427 WARN_ON(error);
1420 } 1428 }
1421 mutex_unlock(&netcp_modules_lock);
1422 } 1429 }
1423} 1430}
1424 1431
@@ -1432,6 +1439,7 @@ static void netcp_set_rx_mode(struct net_device *ndev)
1432 ndev->flags & IFF_ALLMULTI || 1439 ndev->flags & IFF_ALLMULTI ||
1433 netdev_mc_count(ndev) > NETCP_MAX_MCAST_ADDR); 1440 netdev_mc_count(ndev) > NETCP_MAX_MCAST_ADDR);
1434 1441
1442 spin_lock(&netcp->lock);
1435 /* first clear all marks */ 1443 /* first clear all marks */
1436 netcp_addr_clear_mark(netcp); 1444 netcp_addr_clear_mark(netcp);
1437 1445
@@ -1450,6 +1458,7 @@ static void netcp_set_rx_mode(struct net_device *ndev)
1450 /* finally sweep and callout into modules */ 1458 /* finally sweep and callout into modules */
1451 netcp_addr_sweep_del(netcp); 1459 netcp_addr_sweep_del(netcp);
1452 netcp_addr_sweep_add(netcp); 1460 netcp_addr_sweep_add(netcp);
1461 spin_unlock(&netcp->lock);
1453} 1462}
1454 1463
1455static void netcp_free_navigator_resources(struct netcp_intf *netcp) 1464static void netcp_free_navigator_resources(struct netcp_intf *netcp)
@@ -1614,7 +1623,6 @@ static int netcp_ndo_open(struct net_device *ndev)
1614 goto fail; 1623 goto fail;
1615 } 1624 }
1616 1625
1617 mutex_lock(&netcp_modules_lock);
1618 for_each_module(netcp, intf_modpriv) { 1626 for_each_module(netcp, intf_modpriv) {
1619 module = intf_modpriv->netcp_module; 1627 module = intf_modpriv->netcp_module;
1620 if (module->open) { 1628 if (module->open) {
@@ -1625,7 +1633,6 @@ static int netcp_ndo_open(struct net_device *ndev)
1625 } 1633 }
1626 } 1634 }
1627 } 1635 }
1628 mutex_unlock(&netcp_modules_lock);
1629 1636
1630 napi_enable(&netcp->rx_napi); 1637 napi_enable(&netcp->rx_napi);
1631 napi_enable(&netcp->tx_napi); 1638 napi_enable(&netcp->tx_napi);
@@ -1642,7 +1649,6 @@ fail_open:
1642 if (module->close) 1649 if (module->close)
1643 module->close(intf_modpriv->module_priv, ndev); 1650 module->close(intf_modpriv->module_priv, ndev);
1644 } 1651 }
1645 mutex_unlock(&netcp_modules_lock);
1646 1652
1647fail: 1653fail:
1648 netcp_free_navigator_resources(netcp); 1654 netcp_free_navigator_resources(netcp);
@@ -1666,7 +1672,6 @@ static int netcp_ndo_stop(struct net_device *ndev)
1666 napi_disable(&netcp->rx_napi); 1672 napi_disable(&netcp->rx_napi);
1667 napi_disable(&netcp->tx_napi); 1673 napi_disable(&netcp->tx_napi);
1668 1674
1669 mutex_lock(&netcp_modules_lock);
1670 for_each_module(netcp, intf_modpriv) { 1675 for_each_module(netcp, intf_modpriv) {
1671 module = intf_modpriv->netcp_module; 1676 module = intf_modpriv->netcp_module;
1672 if (module->close) { 1677 if (module->close) {
@@ -1675,7 +1680,6 @@ static int netcp_ndo_stop(struct net_device *ndev)
1675 dev_err(netcp->ndev_dev, "Close failed\n"); 1680 dev_err(netcp->ndev_dev, "Close failed\n");
1676 } 1681 }
1677 } 1682 }
1678 mutex_unlock(&netcp_modules_lock);
1679 1683
1680 /* Recycle Rx descriptors from completion queue */ 1684 /* Recycle Rx descriptors from completion queue */
1681 netcp_empty_rx_queue(netcp); 1685 netcp_empty_rx_queue(netcp);
@@ -1703,7 +1707,6 @@ static int netcp_ndo_ioctl(struct net_device *ndev,
1703 if (!netif_running(ndev)) 1707 if (!netif_running(ndev))
1704 return -EINVAL; 1708 return -EINVAL;
1705 1709
1706 mutex_lock(&netcp_modules_lock);
1707 for_each_module(netcp, intf_modpriv) { 1710 for_each_module(netcp, intf_modpriv) {
1708 module = intf_modpriv->netcp_module; 1711 module = intf_modpriv->netcp_module;
1709 if (!module->ioctl) 1712 if (!module->ioctl)
@@ -1719,7 +1722,6 @@ static int netcp_ndo_ioctl(struct net_device *ndev,
1719 } 1722 }
1720 1723
1721out: 1724out:
1722 mutex_unlock(&netcp_modules_lock);
1723 return (ret == 0) ? 0 : err; 1725 return (ret == 0) ? 0 : err;
1724} 1726}
1725 1727
@@ -1754,11 +1756,12 @@ static int netcp_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid)
1754 struct netcp_intf *netcp = netdev_priv(ndev); 1756 struct netcp_intf *netcp = netdev_priv(ndev);
1755 struct netcp_intf_modpriv *intf_modpriv; 1757 struct netcp_intf_modpriv *intf_modpriv;
1756 struct netcp_module *module; 1758 struct netcp_module *module;
1759 unsigned long flags;
1757 int err = 0; 1760 int err = 0;
1758 1761
1759 dev_dbg(netcp->ndev_dev, "adding rx vlan id: %d\n", vid); 1762 dev_dbg(netcp->ndev_dev, "adding rx vlan id: %d\n", vid);
1760 1763
1761 mutex_lock(&netcp_modules_lock); 1764 spin_lock_irqsave(&netcp->lock, flags);
1762 for_each_module(netcp, intf_modpriv) { 1765 for_each_module(netcp, intf_modpriv) {
1763 module = intf_modpriv->netcp_module; 1766 module = intf_modpriv->netcp_module;
1764 if ((module->add_vid) && (vid != 0)) { 1767 if ((module->add_vid) && (vid != 0)) {
@@ -1770,7 +1773,8 @@ static int netcp_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid)
1770 } 1773 }
1771 } 1774 }
1772 } 1775 }
1773 mutex_unlock(&netcp_modules_lock); 1776 spin_unlock_irqrestore(&netcp->lock, flags);
1777
1774 return err; 1778 return err;
1775} 1779}
1776 1780
@@ -1779,11 +1783,12 @@ static int netcp_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
1779 struct netcp_intf *netcp = netdev_priv(ndev); 1783 struct netcp_intf *netcp = netdev_priv(ndev);
1780 struct netcp_intf_modpriv *intf_modpriv; 1784 struct netcp_intf_modpriv *intf_modpriv;
1781 struct netcp_module *module; 1785 struct netcp_module *module;
1786 unsigned long flags;
1782 int err = 0; 1787 int err = 0;
1783 1788
1784 dev_dbg(netcp->ndev_dev, "removing rx vlan id: %d\n", vid); 1789 dev_dbg(netcp->ndev_dev, "removing rx vlan id: %d\n", vid);
1785 1790
1786 mutex_lock(&netcp_modules_lock); 1791 spin_lock_irqsave(&netcp->lock, flags);
1787 for_each_module(netcp, intf_modpriv) { 1792 for_each_module(netcp, intf_modpriv) {
1788 module = intf_modpriv->netcp_module; 1793 module = intf_modpriv->netcp_module;
1789 if (module->del_vid) { 1794 if (module->del_vid) {
@@ -1795,7 +1800,7 @@ static int netcp_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
1795 } 1800 }
1796 } 1801 }
1797 } 1802 }
1798 mutex_unlock(&netcp_modules_lock); 1803 spin_unlock_irqrestore(&netcp->lock, flags);
1799 return err; 1804 return err;
1800} 1805}
1801 1806
@@ -2040,7 +2045,6 @@ static int netcp_probe(struct platform_device *pdev)
2040 struct device_node *child, *interfaces; 2045 struct device_node *child, *interfaces;
2041 struct netcp_device *netcp_device; 2046 struct netcp_device *netcp_device;
2042 struct device *dev = &pdev->dev; 2047 struct device *dev = &pdev->dev;
2043 struct netcp_module *module;
2044 int ret; 2048 int ret;
2045 2049
2046 if (!node) { 2050 if (!node) {
@@ -2087,14 +2091,6 @@ static int netcp_probe(struct platform_device *pdev)
2087 /* Add the device instance to the list */ 2091 /* Add the device instance to the list */
2088 list_add_tail(&netcp_device->device_list, &netcp_devices); 2092 list_add_tail(&netcp_device->device_list, &netcp_devices);
2089 2093
2090 /* Probe & attach any modules already registered */
2091 mutex_lock(&netcp_modules_lock);
2092 for_each_netcp_module(module) {
2093 ret = netcp_module_probe(netcp_device, module);
2094 if (ret < 0)
2095 dev_err(dev, "module(%s) probe failed\n", module->name);
2096 }
2097 mutex_unlock(&netcp_modules_lock);
2098 return 0; 2094 return 0;
2099 2095
2100probe_quit_interface: 2096probe_quit_interface:
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 6f16d6aaf7b7..4e70e7586a09 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -77,6 +77,7 @@
77#define GBENU_ALE_OFFSET 0x1e000 77#define GBENU_ALE_OFFSET 0x1e000
78#define GBENU_HOST_PORT_NUM 0 78#define GBENU_HOST_PORT_NUM 0
79#define GBENU_NUM_ALE_ENTRIES 1024 79#define GBENU_NUM_ALE_ENTRIES 1024
80#define GBENU_SGMII_MODULE_SIZE 0x100
80 81
81/* 10G Ethernet SS defines */ 82/* 10G Ethernet SS defines */
82#define XGBE_MODULE_NAME "netcp-xgbe" 83#define XGBE_MODULE_NAME "netcp-xgbe"
@@ -149,8 +150,8 @@
149#define XGBE_STATS2_MODULE 2 150#define XGBE_STATS2_MODULE 2
150 151
151/* s: 0-based slave_port */ 152/* s: 0-based slave_port */
152#define SGMII_BASE(s) \ 153#define SGMII_BASE(d, s) \
153 (((s) < 2) ? gbe_dev->sgmii_port_regs : gbe_dev->sgmii_port34_regs) 154 (((s) < 2) ? (d)->sgmii_port_regs : (d)->sgmii_port34_regs)
154 155
155#define GBE_TX_QUEUE 648 156#define GBE_TX_QUEUE 648
156#define GBE_TXHOOK_ORDER 0 157#define GBE_TXHOOK_ORDER 0
@@ -1997,13 +1998,8 @@ static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
1997 return; 1998 return;
1998 1999
1999 if (!SLAVE_LINK_IS_XGMII(slave)) { 2000 if (!SLAVE_LINK_IS_XGMII(slave)) {
2000 if (gbe_dev->ss_version == GBE_SS_VERSION_14) 2001 sgmii_link_state =
2001 sgmii_link_state = 2002 netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
2002 netcp_sgmii_get_port_link(SGMII_BASE(sp), sp);
2003 else
2004 sgmii_link_state =
2005 netcp_sgmii_get_port_link(
2006 gbe_dev->sgmii_port_regs, sp);
2007 } 2003 }
2008 2004
2009 phy_link_state = gbe_phy_link_status(slave); 2005 phy_link_state = gbe_phy_link_status(slave);
@@ -2100,17 +2096,11 @@ static void gbe_port_config(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
2100static void gbe_sgmii_rtreset(struct gbe_priv *priv, 2096static void gbe_sgmii_rtreset(struct gbe_priv *priv,
2101 struct gbe_slave *slave, bool set) 2097 struct gbe_slave *slave, bool set)
2102{ 2098{
2103 void __iomem *sgmii_port_regs;
2104
2105 if (SLAVE_LINK_IS_XGMII(slave)) 2099 if (SLAVE_LINK_IS_XGMII(slave))
2106 return; 2100 return;
2107 2101
2108 if ((priv->ss_version == GBE_SS_VERSION_14) && (slave->slave_num >= 2)) 2102 netcp_sgmii_rtreset(SGMII_BASE(priv, slave->slave_num),
2109 sgmii_port_regs = priv->sgmii_port34_regs; 2103 slave->slave_num, set);
2110 else
2111 sgmii_port_regs = priv->sgmii_port_regs;
2112
2113 netcp_sgmii_rtreset(sgmii_port_regs, slave->slave_num, set);
2114} 2104}
2115 2105
2116static void gbe_slave_stop(struct gbe_intf *intf) 2106static void gbe_slave_stop(struct gbe_intf *intf)
@@ -2136,17 +2126,12 @@ static void gbe_slave_stop(struct gbe_intf *intf)
2136 2126
2137static void gbe_sgmii_config(struct gbe_priv *priv, struct gbe_slave *slave) 2127static void gbe_sgmii_config(struct gbe_priv *priv, struct gbe_slave *slave)
2138{ 2128{
2139 void __iomem *sgmii_port_regs; 2129 if (SLAVE_LINK_IS_XGMII(slave))
2140 2130 return;
2141 sgmii_port_regs = priv->sgmii_port_regs;
2142 if ((priv->ss_version == GBE_SS_VERSION_14) && (slave->slave_num >= 2))
2143 sgmii_port_regs = priv->sgmii_port34_regs;
2144 2131
2145 if (!SLAVE_LINK_IS_XGMII(slave)) { 2132 netcp_sgmii_reset(SGMII_BASE(priv, slave->slave_num), slave->slave_num);
2146 netcp_sgmii_reset(sgmii_port_regs, slave->slave_num); 2133 netcp_sgmii_config(SGMII_BASE(priv, slave->slave_num), slave->slave_num,
2147 netcp_sgmii_config(sgmii_port_regs, slave->slave_num, 2134 slave->link_interface);
2148 slave->link_interface);
2149 }
2150} 2135}
2151 2136
2152static int gbe_slave_open(struct gbe_intf *gbe_intf) 2137static int gbe_slave_open(struct gbe_intf *gbe_intf)
@@ -2652,8 +2637,10 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
2652 mac_phy_link = true; 2637 mac_phy_link = true;
2653 2638
2654 slave->open = true; 2639 slave->open = true;
2655 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) 2640 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) {
2641 of_node_put(port);
2656 break; 2642 break;
2643 }
2657 } 2644 }
2658 2645
2659 /* of_phy_connect() is needed only for MAC-PHY interface */ 2646 /* of_phy_connect() is needed only for MAC-PHY interface */
@@ -2997,6 +2984,14 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
2997 gbe_dev->switch_regs = regs; 2984 gbe_dev->switch_regs = regs;
2998 2985
2999 gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + GBENU_SGMII_MODULE_OFFSET; 2986 gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + GBENU_SGMII_MODULE_OFFSET;
2987
2988 /* Although sgmii modules are mem mapped to one contiguous
2989 * region on GBENU devices, setting sgmii_port34_regs allows
2990 * consistent code when accessing sgmii api
2991 */
2992 gbe_dev->sgmii_port34_regs = gbe_dev->sgmii_port_regs +
2993 (2 * GBENU_SGMII_MODULE_SIZE);
2994
3000 gbe_dev->host_port_regs = gbe_dev->switch_regs + GBENU_HOST_PORT_OFFSET; 2995 gbe_dev->host_port_regs = gbe_dev->switch_regs + GBENU_HOST_PORT_OFFSET;
3001 2996
3002 for (i = 0; i < (gbe_dev->max_num_ports); i++) 2997 for (i = 0; i < (gbe_dev->max_num_ports); i++)
@@ -3144,8 +3139,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
3144 continue; 3139 continue;
3145 } 3140 }
3146 gbe_dev->num_slaves++; 3141 gbe_dev->num_slaves++;
3147 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) 3142 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) {
3143 of_node_put(interface);
3148 break; 3144 break;
3145 }
3149 } 3146 }
3150 of_node_put(interfaces); 3147 of_node_put(interfaces);
3151 3148
diff --git a/drivers/net/ethernet/via/Kconfig b/drivers/net/ethernet/via/Kconfig
index 2f1264b882b9..d3d094742a7e 100644
--- a/drivers/net/ethernet/via/Kconfig
+++ b/drivers/net/ethernet/via/Kconfig
@@ -17,7 +17,7 @@ if NET_VENDOR_VIA
17 17
18config VIA_RHINE 18config VIA_RHINE
19 tristate "VIA Rhine support" 19 tristate "VIA Rhine support"
20 depends on (PCI || OF_IRQ) 20 depends on PCI || (OF_IRQ && GENERIC_PCI_IOMAP)
21 depends on HAS_DMA 21 depends on HAS_DMA
22 select CRC32 22 select CRC32
23 select MII 23 select MII
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index a83263743665..2b7550c43f78 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -2134,10 +2134,11 @@ static int rhine_rx(struct net_device *dev, int limit)
2134 } 2134 }
2135 2135
2136 skb_put(skb, pkt_len); 2136 skb_put(skb, pkt_len);
2137 skb->protocol = eth_type_trans(skb, dev);
2138 2137
2139 rhine_rx_vlan_tag(skb, desc, data_size); 2138 rhine_rx_vlan_tag(skb, desc, data_size);
2140 2139
2140 skb->protocol = eth_type_trans(skb, dev);
2141
2141 netif_receive_skb(skb); 2142 netif_receive_skb(skb);
2142 2143
2143 u64_stats_update_begin(&rp->rx_stats.syncp); 2144 u64_stats_update_begin(&rp->rx_stats.syncp);
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 6008eee01a33..cf468c87ce57 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -828,6 +828,8 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
828 if (!phydev) 828 if (!phydev)
829 dev_info(dev, 829 dev_info(dev,
830 "MDIO of the phy is not registered yet\n"); 830 "MDIO of the phy is not registered yet\n");
831 else
832 put_device(&phydev->dev);
831 return 0; 833 return 0;
832 } 834 }
833 835
diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c
index b5f4a78da828..2d3848c9dc35 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -1011,11 +1011,11 @@ static void fjes_hw_update_zone_task(struct work_struct *work)
1011 set_bit(epidx, &irq_bit); 1011 set_bit(epidx, &irq_bit);
1012 break; 1012 break;
1013 } 1013 }
1014 }
1015
1016 hw->ep_shm_info[epidx].es_status = info[epidx].es_status;
1017 hw->ep_shm_info[epidx].zone = info[epidx].zone;
1018 1014
1015 hw->ep_shm_info[epidx].es_status =
1016 info[epidx].es_status;
1017 hw->ep_shm_info[epidx].zone = info[epidx].zone;
1018 }
1019 break; 1019 break;
1020 } 1020 }
1021 1021
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index da3259ce7c8d..445071c163cb 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -126,6 +126,8 @@ static void geneve_rx(struct geneve_sock *gs, struct sk_buff *skb)
126 __be32 addr; 126 __be32 addr;
127 int err; 127 int err;
128 128
129 iph = ip_hdr(skb); /* outer IP header... */
130
129 if (gs->collect_md) { 131 if (gs->collect_md) {
130 static u8 zero_vni[3]; 132 static u8 zero_vni[3];
131 133
@@ -133,7 +135,6 @@ static void geneve_rx(struct geneve_sock *gs, struct sk_buff *skb)
133 addr = 0; 135 addr = 0;
134 } else { 136 } else {
135 vni = gnvh->vni; 137 vni = gnvh->vni;
136 iph = ip_hdr(skb); /* Still outer IP header... */
137 addr = iph->saddr; 138 addr = iph->saddr;
138 } 139 }
139 140
@@ -178,7 +179,6 @@ static void geneve_rx(struct geneve_sock *gs, struct sk_buff *skb)
178 179
179 skb_reset_network_header(skb); 180 skb_reset_network_header(skb);
180 181
181 iph = ip_hdr(skb); /* Now inner IP header... */
182 err = IP_ECN_decapsulate(iph, skb); 182 err = IP_ECN_decapsulate(iph, skb);
183 183
184 if (unlikely(err)) { 184 if (unlikely(err)) {
@@ -594,14 +594,12 @@ static struct rtable *geneve_get_rt(struct sk_buff *skb,
594 rt = ip_route_output_key(geneve->net, fl4); 594 rt = ip_route_output_key(geneve->net, fl4);
595 if (IS_ERR(rt)) { 595 if (IS_ERR(rt)) {
596 netdev_dbg(dev, "no route to %pI4\n", &fl4->daddr); 596 netdev_dbg(dev, "no route to %pI4\n", &fl4->daddr);
597 dev->stats.tx_carrier_errors++; 597 return ERR_PTR(-ENETUNREACH);
598 return rt;
599 } 598 }
600 if (rt->dst.dev == dev) { /* is this necessary? */ 599 if (rt->dst.dev == dev) { /* is this necessary? */
601 netdev_dbg(dev, "circular route to %pI4\n", &fl4->daddr); 600 netdev_dbg(dev, "circular route to %pI4\n", &fl4->daddr);
602 dev->stats.collisions++;
603 ip_rt_put(rt); 601 ip_rt_put(rt);
604 return ERR_PTR(-EINVAL); 602 return ERR_PTR(-ELOOP);
605 } 603 }
606 return rt; 604 return rt;
607} 605}
@@ -626,12 +624,13 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
626 struct geneve_sock *gs = geneve->sock; 624 struct geneve_sock *gs = geneve->sock;
627 struct ip_tunnel_info *info = NULL; 625 struct ip_tunnel_info *info = NULL;
628 struct rtable *rt = NULL; 626 struct rtable *rt = NULL;
627 const struct iphdr *iip; /* interior IP header */
628 int err = -EINVAL;
629 struct flowi4 fl4; 629 struct flowi4 fl4;
630 __u8 tos, ttl; 630 __u8 tos, ttl;
631 __be16 sport; 631 __be16 sport;
632 bool udp_csum; 632 bool udp_csum;
633 __be16 df; 633 __be16 df;
634 int err;
635 634
636 if (geneve->collect_md) { 635 if (geneve->collect_md) {
637 info = skb_tunnel_info(skb); 636 info = skb_tunnel_info(skb);
@@ -646,13 +645,15 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
646 rt = geneve_get_rt(skb, dev, &fl4, info); 645 rt = geneve_get_rt(skb, dev, &fl4, info);
647 if (IS_ERR(rt)) { 646 if (IS_ERR(rt)) {
648 netdev_dbg(dev, "no route to %pI4\n", &fl4.daddr); 647 netdev_dbg(dev, "no route to %pI4\n", &fl4.daddr);
649 dev->stats.tx_carrier_errors++; 648 err = PTR_ERR(rt);
650 goto tx_error; 649 goto tx_error;
651 } 650 }
652 651
653 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 652 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
654 skb_reset_mac_header(skb); 653 skb_reset_mac_header(skb);
655 654
655 iip = ip_hdr(skb);
656
656 if (info) { 657 if (info) {
657 const struct ip_tunnel_key *key = &info->key; 658 const struct ip_tunnel_key *key = &info->key;
658 u8 *opts = NULL; 659 u8 *opts = NULL;
@@ -668,19 +669,16 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
668 if (unlikely(err)) 669 if (unlikely(err))
669 goto err; 670 goto err;
670 671
671 tos = key->tos; 672 tos = ip_tunnel_ecn_encap(key->tos, iip, skb);
672 ttl = key->ttl; 673 ttl = key->ttl;
673 df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; 674 df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
674 } else { 675 } else {
675 const struct iphdr *iip; /* interior IP header */
676
677 udp_csum = false; 676 udp_csum = false;
678 err = geneve_build_skb(rt, skb, 0, geneve->vni, 677 err = geneve_build_skb(rt, skb, 0, geneve->vni,
679 0, NULL, udp_csum); 678 0, NULL, udp_csum);
680 if (unlikely(err)) 679 if (unlikely(err))
681 goto err; 680 goto err;
682 681
683 iip = ip_hdr(skb);
684 tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, iip, skb); 682 tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, iip, skb);
685 ttl = geneve->ttl; 683 ttl = geneve->ttl;
686 if (!ttl && IN_MULTICAST(ntohl(fl4.daddr))) 684 if (!ttl && IN_MULTICAST(ntohl(fl4.daddr)))
@@ -699,10 +697,37 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
699tx_error: 697tx_error:
700 dev_kfree_skb(skb); 698 dev_kfree_skb(skb);
701err: 699err:
702 dev->stats.tx_errors++; 700 if (err == -ELOOP)
701 dev->stats.collisions++;
702 else if (err == -ENETUNREACH)
703 dev->stats.tx_carrier_errors++;
704 else
705 dev->stats.tx_errors++;
703 return NETDEV_TX_OK; 706 return NETDEV_TX_OK;
704} 707}
705 708
709static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
710{
711 struct ip_tunnel_info *info = skb_tunnel_info(skb);
712 struct geneve_dev *geneve = netdev_priv(dev);
713 struct rtable *rt;
714 struct flowi4 fl4;
715
716 if (ip_tunnel_info_af(info) != AF_INET)
717 return -EINVAL;
718
719 rt = geneve_get_rt(skb, dev, &fl4, info);
720 if (IS_ERR(rt))
721 return PTR_ERR(rt);
722
723 ip_rt_put(rt);
724 info->key.u.ipv4.src = fl4.saddr;
725 info->key.tp_src = udp_flow_src_port(geneve->net, skb,
726 1, USHRT_MAX, true);
727 info->key.tp_dst = geneve->dst_port;
728 return 0;
729}
730
706static const struct net_device_ops geneve_netdev_ops = { 731static const struct net_device_ops geneve_netdev_ops = {
707 .ndo_init = geneve_init, 732 .ndo_init = geneve_init,
708 .ndo_uninit = geneve_uninit, 733 .ndo_uninit = geneve_uninit,
@@ -713,6 +738,7 @@ static const struct net_device_ops geneve_netdev_ops = {
713 .ndo_change_mtu = eth_change_mtu, 738 .ndo_change_mtu = eth_change_mtu,
714 .ndo_validate_addr = eth_validate_addr, 739 .ndo_validate_addr = eth_validate_addr,
715 .ndo_set_mac_address = eth_mac_addr, 740 .ndo_set_mac_address = eth_mac_addr,
741 .ndo_fill_metadata_dst = geneve_fill_metadata_dst,
716}; 742};
717 743
718static void geneve_get_drvinfo(struct net_device *dev, 744static void geneve_get_drvinfo(struct net_device *dev,
@@ -748,12 +774,8 @@ static void geneve_setup(struct net_device *dev)
748 dev->features |= NETIF_F_RXCSUM; 774 dev->features |= NETIF_F_RXCSUM;
749 dev->features |= NETIF_F_GSO_SOFTWARE; 775 dev->features |= NETIF_F_GSO_SOFTWARE;
750 776
751 dev->vlan_features = dev->features;
752 dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
753
754 dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM; 777 dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
755 dev->hw_features |= NETIF_F_GSO_SOFTWARE; 778 dev->hw_features |= NETIF_F_GSO_SOFTWARE;
756 dev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
757 779
758 netif_keep_dst(dev); 780 netif_keep_dst(dev);
759 dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE; 781 dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
@@ -819,7 +841,7 @@ static struct geneve_dev *geneve_find_dev(struct geneve_net *gn,
819 841
820static int geneve_configure(struct net *net, struct net_device *dev, 842static int geneve_configure(struct net *net, struct net_device *dev,
821 __be32 rem_addr, __u32 vni, __u8 ttl, __u8 tos, 843 __be32 rem_addr, __u32 vni, __u8 ttl, __u8 tos,
822 __u16 dst_port, bool metadata) 844 __be16 dst_port, bool metadata)
823{ 845{
824 struct geneve_net *gn = net_generic(net, geneve_net_id); 846 struct geneve_net *gn = net_generic(net, geneve_net_id);
825 struct geneve_dev *t, *geneve = netdev_priv(dev); 847 struct geneve_dev *t, *geneve = netdev_priv(dev);
@@ -844,10 +866,10 @@ static int geneve_configure(struct net *net, struct net_device *dev,
844 866
845 geneve->ttl = ttl; 867 geneve->ttl = ttl;
846 geneve->tos = tos; 868 geneve->tos = tos;
847 geneve->dst_port = htons(dst_port); 869 geneve->dst_port = dst_port;
848 geneve->collect_md = metadata; 870 geneve->collect_md = metadata;
849 871
850 t = geneve_find_dev(gn, htons(dst_port), rem_addr, geneve->vni, 872 t = geneve_find_dev(gn, dst_port, rem_addr, geneve->vni,
851 &tun_on_same_port, &tun_collect_md); 873 &tun_on_same_port, &tun_collect_md);
852 if (t) 874 if (t)
853 return -EBUSY; 875 return -EBUSY;
@@ -871,17 +893,17 @@ static int geneve_configure(struct net *net, struct net_device *dev,
871static int geneve_newlink(struct net *net, struct net_device *dev, 893static int geneve_newlink(struct net *net, struct net_device *dev,
872 struct nlattr *tb[], struct nlattr *data[]) 894 struct nlattr *tb[], struct nlattr *data[])
873{ 895{
874 __u16 dst_port = GENEVE_UDP_PORT; 896 __be16 dst_port = htons(GENEVE_UDP_PORT);
875 __u8 ttl = 0, tos = 0; 897 __u8 ttl = 0, tos = 0;
876 bool metadata = false; 898 bool metadata = false;
877 __be32 rem_addr; 899 __be32 rem_addr = 0;
878 __u32 vni; 900 __u32 vni = 0;
879 901
880 if (!data[IFLA_GENEVE_ID] || !data[IFLA_GENEVE_REMOTE]) 902 if (data[IFLA_GENEVE_ID])
881 return -EINVAL; 903 vni = nla_get_u32(data[IFLA_GENEVE_ID]);
882 904
883 vni = nla_get_u32(data[IFLA_GENEVE_ID]); 905 if (data[IFLA_GENEVE_REMOTE])
884 rem_addr = nla_get_in_addr(data[IFLA_GENEVE_REMOTE]); 906 rem_addr = nla_get_in_addr(data[IFLA_GENEVE_REMOTE]);
885 907
886 if (data[IFLA_GENEVE_TTL]) 908 if (data[IFLA_GENEVE_TTL])
887 ttl = nla_get_u8(data[IFLA_GENEVE_TTL]); 909 ttl = nla_get_u8(data[IFLA_GENEVE_TTL]);
@@ -890,7 +912,7 @@ static int geneve_newlink(struct net *net, struct net_device *dev,
890 tos = nla_get_u8(data[IFLA_GENEVE_TOS]); 912 tos = nla_get_u8(data[IFLA_GENEVE_TOS]);
891 913
892 if (data[IFLA_GENEVE_PORT]) 914 if (data[IFLA_GENEVE_PORT])
893 dst_port = nla_get_u16(data[IFLA_GENEVE_PORT]); 915 dst_port = nla_get_be16(data[IFLA_GENEVE_PORT]);
894 916
895 if (data[IFLA_GENEVE_COLLECT_METADATA]) 917 if (data[IFLA_GENEVE_COLLECT_METADATA])
896 metadata = true; 918 metadata = true;
@@ -913,7 +935,7 @@ static size_t geneve_get_size(const struct net_device *dev)
913 nla_total_size(sizeof(struct in_addr)) + /* IFLA_GENEVE_REMOTE */ 935 nla_total_size(sizeof(struct in_addr)) + /* IFLA_GENEVE_REMOTE */
914 nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TTL */ 936 nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TTL */
915 nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TOS */ 937 nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TOS */
916 nla_total_size(sizeof(__u16)) + /* IFLA_GENEVE_PORT */ 938 nla_total_size(sizeof(__be16)) + /* IFLA_GENEVE_PORT */
917 nla_total_size(0) + /* IFLA_GENEVE_COLLECT_METADATA */ 939 nla_total_size(0) + /* IFLA_GENEVE_COLLECT_METADATA */
918 0; 940 0;
919} 941}
@@ -935,7 +957,7 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
935 nla_put_u8(skb, IFLA_GENEVE_TOS, geneve->tos)) 957 nla_put_u8(skb, IFLA_GENEVE_TOS, geneve->tos))
936 goto nla_put_failure; 958 goto nla_put_failure;
937 959
938 if (nla_put_u16(skb, IFLA_GENEVE_PORT, ntohs(geneve->dst_port))) 960 if (nla_put_be16(skb, IFLA_GENEVE_PORT, geneve->dst_port))
939 goto nla_put_failure; 961 goto nla_put_failure;
940 962
941 if (geneve->collect_md) { 963 if (geneve->collect_md) {
@@ -975,7 +997,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
975 if (IS_ERR(dev)) 997 if (IS_ERR(dev))
976 return dev; 998 return dev;
977 999
978 err = geneve_configure(net, dev, 0, 0, 0, 0, dst_port, true); 1000 err = geneve_configure(net, dev, 0, 0, 0, 0, htons(dst_port), true);
979 if (err) { 1001 if (err) {
980 free_netdev(dev); 1002 free_netdev(dev);
981 return ERR_PTR(err); 1003 return ERR_PTR(err);
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 58ae11a14bb6..64bb44d5d867 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -1031,7 +1031,6 @@ static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud)
1031static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed) 1031static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
1032{ 1032{
1033 struct ali_ircc_cb *self = priv; 1033 struct ali_ircc_cb *self = priv;
1034 unsigned long flags;
1035 int iobase; 1034 int iobase;
1036 int fcr; /* FIFO control reg */ 1035 int fcr; /* FIFO control reg */
1037 int lcr; /* Line control reg */ 1036 int lcr; /* Line control reg */
@@ -1061,8 +1060,6 @@ static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
1061 /* Update accounting for new speed */ 1060 /* Update accounting for new speed */
1062 self->io.speed = speed; 1061 self->io.speed = speed;
1063 1062
1064 spin_lock_irqsave(&self->lock, flags);
1065
1066 divisor = 115200/speed; 1063 divisor = 115200/speed;
1067 1064
1068 fcr = UART_FCR_ENABLE_FIFO; 1065 fcr = UART_FCR_ENABLE_FIFO;
@@ -1089,9 +1086,6 @@ static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
1089 /* without this, the connection will be broken after come back from FIR speed, 1086 /* without this, the connection will be broken after come back from FIR speed,
1090 but with this, the SIR connection is harder to established */ 1087 but with this, the SIR connection is harder to established */
1091 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase+UART_MCR); 1088 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase+UART_MCR);
1092
1093 spin_unlock_irqrestore(&self->lock, flags);
1094
1095} 1089}
1096 1090
1097static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed) 1091static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed)
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index edd77342773a..197c93937c2d 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -137,7 +137,7 @@ static const struct proto_ops macvtap_socket_ops;
137#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \ 137#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
138 NETIF_F_TSO6 | NETIF_F_UFO) 138 NETIF_F_TSO6 | NETIF_F_UFO)
139#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO) 139#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
140#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG) 140#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG | NETIF_F_FRAGLIST)
141 141
142static struct macvlan_dev *macvtap_get_vlan_rcu(const struct net_device *dev) 142static struct macvlan_dev *macvtap_get_vlan_rcu(const struct net_device *dev)
143{ 143{
@@ -1111,10 +1111,10 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
1111 return 0; 1111 return 0;
1112 1112
1113 case TUNSETSNDBUF: 1113 case TUNSETSNDBUF:
1114 if (get_user(u, up)) 1114 if (get_user(s, sp))
1115 return -EFAULT; 1115 return -EFAULT;
1116 1116
1117 q->sk.sk_sndbuf = u; 1117 q->sk.sk_sndbuf = s;
1118 return 0; 1118 return 0;
1119 1119
1120 case TUNGETVNETHDRSZ: 1120 case TUNGETVNETHDRSZ:
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index c5ad98ace5d0..436972b2a746 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -122,6 +122,11 @@ config MICREL_PHY
122 ---help--- 122 ---help---
123 Supports the KSZ9021, VSC8201, KS8001 PHYs. 123 Supports the KSZ9021, VSC8201, KS8001 PHYs.
124 124
125config DP83848_PHY
126 tristate "Driver for Texas Instruments DP83848 PHY"
127 ---help---
128 Supports the DP83848 PHY.
129
125config DP83867_PHY 130config DP83867_PHY
126 tristate "Drivers for Texas Instruments DP83867 Gigabit PHY" 131 tristate "Drivers for Texas Instruments DP83867 Gigabit PHY"
127 ---help--- 132 ---help---
@@ -168,8 +173,6 @@ config MDIO_OCTEON
168 busses. It is required by the Octeon and ThunderX ethernet device 173 busses. It is required by the Octeon and ThunderX ethernet device
169 drivers. 174 drivers.
170 175
171 If in doubt, say Y.
172
173config MDIO_SUN4I 176config MDIO_SUN4I
174 tristate "Allwinner sun4i MDIO interface support" 177 tristate "Allwinner sun4i MDIO interface support"
175 depends on ARCH_SUNXI 178 depends on ARCH_SUNXI
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 87f079c4b2c7..b74822463930 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
24obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o 24obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o
25obj-$(CONFIG_NATIONAL_PHY) += national.o 25obj-$(CONFIG_NATIONAL_PHY) += national.o
26obj-$(CONFIG_DP83640_PHY) += dp83640.o 26obj-$(CONFIG_DP83640_PHY) += dp83640.o
27obj-$(CONFIG_DP83848_PHY) += dp83848.o
27obj-$(CONFIG_DP83867_PHY) += dp83867.o 28obj-$(CONFIG_DP83867_PHY) += dp83867.o
28obj-$(CONFIG_STE10XP) += ste10Xp.o 29obj-$(CONFIG_STE10XP) += ste10Xp.o
29obj-$(CONFIG_MICREL_PHY) += micrel.o 30obj-$(CONFIG_MICREL_PHY) += micrel.o
diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
new file mode 100644
index 000000000000..5ce9bef54468
--- /dev/null
+++ b/drivers/net/phy/dp83848.c
@@ -0,0 +1,99 @@
1/*
2 * Driver for the Texas Instruments DP83848 PHY
3 *
4 * Copyright (C) 2015 Texas Instruments Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/phy.h>
18
19#define DP83848_PHY_ID 0x20005c90
20
21/* Registers */
22#define DP83848_MICR 0x11
23#define DP83848_MISR 0x12
24
25/* MICR Register Fields */
26#define DP83848_MICR_INT_OE BIT(0) /* Interrupt Output Enable */
27#define DP83848_MICR_INTEN BIT(1) /* Interrupt Enable */
28
29/* MISR Register Fields */
30#define DP83848_MISR_RHF_INT_EN BIT(0) /* Receive Error Counter */
31#define DP83848_MISR_FHF_INT_EN BIT(1) /* False Carrier Counter */
32#define DP83848_MISR_ANC_INT_EN BIT(2) /* Auto-negotiation complete */
33#define DP83848_MISR_DUP_INT_EN BIT(3) /* Duplex Status */
34#define DP83848_MISR_SPD_INT_EN BIT(4) /* Speed status */
35#define DP83848_MISR_LINK_INT_EN BIT(5) /* Link status */
36#define DP83848_MISR_ED_INT_EN BIT(6) /* Energy detect */
37#define DP83848_MISR_LQM_INT_EN BIT(7) /* Link Quality Monitor */
38
39static int dp83848_ack_interrupt(struct phy_device *phydev)
40{
41 int err = phy_read(phydev, DP83848_MISR);
42
43 return err < 0 ? err : 0;
44}
45
46static int dp83848_config_intr(struct phy_device *phydev)
47{
48 int err;
49
50 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
51 err = phy_write(phydev, DP83848_MICR,
52 DP83848_MICR_INT_OE |
53 DP83848_MICR_INTEN);
54 if (err < 0)
55 return err;
56
57 return phy_write(phydev, DP83848_MISR,
58 DP83848_MISR_ANC_INT_EN |
59 DP83848_MISR_DUP_INT_EN |
60 DP83848_MISR_SPD_INT_EN |
61 DP83848_MISR_LINK_INT_EN);
62 }
63
64 return phy_write(phydev, DP83848_MICR, 0x0);
65}
66
67static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
68 { DP83848_PHY_ID, 0xfffffff0 },
69 { }
70};
71MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
72
73static struct phy_driver dp83848_driver[] = {
74 {
75 .phy_id = DP83848_PHY_ID,
76 .phy_id_mask = 0xfffffff0,
77 .name = "TI DP83848",
78 .features = PHY_BASIC_FEATURES,
79 .flags = PHY_HAS_INTERRUPT,
80
81 .soft_reset = genphy_soft_reset,
82 .config_init = genphy_config_init,
83 .suspend = genphy_suspend,
84 .resume = genphy_resume,
85 .config_aneg = genphy_config_aneg,
86 .read_status = genphy_read_status,
87
88 /* IRQ related */
89 .ack_interrupt = dp83848_ack_interrupt,
90 .config_intr = dp83848_config_intr,
91
92 .driver = { .owner = THIS_MODULE, },
93 },
94};
95module_phy_driver(dp83848_driver);
96
97MODULE_DESCRIPTION("Texas Instruments DP83848 PHY driver");
98MODULE_AUTHOR("Andrew F. Davis <afd@ti.com");
99MODULE_LICENSE("GPL");
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index fb1299c6326e..e23bf5b90e17 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -220,7 +220,7 @@ int fixed_phy_update_state(struct phy_device *phydev,
220 struct fixed_mdio_bus *fmb = &platform_fmb; 220 struct fixed_mdio_bus *fmb = &platform_fmb;
221 struct fixed_phy *fp; 221 struct fixed_phy *fp;
222 222
223 if (!phydev || !phydev->bus) 223 if (!phydev || phydev->bus != fmb->mii_bus)
224 return -EINVAL; 224 return -EINVAL;
225 225
226 list_for_each_entry(fp, &fmb->phys, node) { 226 list_for_each_entry(fp, &fmb->phys, node) {
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index e6897b6a8a53..5de8d5827536 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -785,6 +785,7 @@ static int marvell_read_status(struct phy_device *phydev)
785 int adv; 785 int adv;
786 int err; 786 int err;
787 int lpa; 787 int lpa;
788 int lpagb;
788 int status = 0; 789 int status = 0;
789 790
790 /* Update the link, but return if there 791 /* Update the link, but return if there
@@ -802,10 +803,17 @@ static int marvell_read_status(struct phy_device *phydev)
802 if (lpa < 0) 803 if (lpa < 0)
803 return lpa; 804 return lpa;
804 805
806 lpagb = phy_read(phydev, MII_STAT1000);
807 if (lpagb < 0)
808 return lpagb;
809
805 adv = phy_read(phydev, MII_ADVERTISE); 810 adv = phy_read(phydev, MII_ADVERTISE);
806 if (adv < 0) 811 if (adv < 0)
807 return adv; 812 return adv;
808 813
814 phydev->lp_advertising = mii_stat1000_to_ethtool_lpa_t(lpagb) |
815 mii_lpa_to_ethtool_lpa_t(lpa);
816
809 lpa &= adv; 817 lpa &= adv;
810 818
811 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX) 819 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
@@ -853,6 +861,7 @@ static int marvell_read_status(struct phy_device *phydev)
853 phydev->speed = SPEED_10; 861 phydev->speed = SPEED_10;
854 862
855 phydev->pause = phydev->asym_pause = 0; 863 phydev->pause = phydev->asym_pause = 0;
864 phydev->lp_advertising = 0;
856 } 865 }
857 866
858 return 0; 867 return 0;
diff --git a/drivers/net/phy/mdio-bcm-unimac.c b/drivers/net/phy/mdio-bcm-unimac.c
index 6a52a7f0fa0d..4bde5e728fe0 100644
--- a/drivers/net/phy/mdio-bcm-unimac.c
+++ b/drivers/net/phy/mdio-bcm-unimac.c
@@ -244,6 +244,7 @@ static const struct of_device_id unimac_mdio_ids[] = {
244 { .compatible = "brcm,unimac-mdio", }, 244 { .compatible = "brcm,unimac-mdio", },
245 { /* sentinel */ }, 245 { /* sentinel */ },
246}; 246};
247MODULE_DEVICE_TABLE(of, unimac_mdio_ids);
247 248
248static struct platform_driver unimac_mdio_driver = { 249static struct platform_driver unimac_mdio_driver = {
249 .driver = { 250 .driver = {
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 7dc21e56a7aa..3bc9f03349f3 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -261,6 +261,7 @@ static const struct of_device_id mdio_gpio_of_match[] = {
261 { .compatible = "virtual,mdio-gpio", }, 261 { .compatible = "virtual,mdio-gpio", },
262 { /* sentinel */ } 262 { /* sentinel */ }
263}; 263};
264MODULE_DEVICE_TABLE(of, mdio_gpio_of_match);
264 265
265static struct platform_driver mdio_gpio_driver = { 266static struct platform_driver mdio_gpio_driver = {
266 .probe = mdio_gpio_probe, 267 .probe = mdio_gpio_probe,
diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c
index 2377c1341172..7fde454fbc4f 100644
--- a/drivers/net/phy/mdio-mux-mmioreg.c
+++ b/drivers/net/phy/mdio-mux-mmioreg.c
@@ -113,12 +113,14 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
113 if (!iprop || len != sizeof(uint32_t)) { 113 if (!iprop || len != sizeof(uint32_t)) {
114 dev_err(&pdev->dev, "mdio-mux child node %s is " 114 dev_err(&pdev->dev, "mdio-mux child node %s is "
115 "missing a 'reg' property\n", np2->full_name); 115 "missing a 'reg' property\n", np2->full_name);
116 of_node_put(np2);
116 return -ENODEV; 117 return -ENODEV;
117 } 118 }
118 if (be32_to_cpup(iprop) & ~s->mask) { 119 if (be32_to_cpup(iprop) & ~s->mask) {
119 dev_err(&pdev->dev, "mdio-mux child node %s has " 120 dev_err(&pdev->dev, "mdio-mux child node %s has "
120 "a 'reg' value with unmasked bits\n", 121 "a 'reg' value with unmasked bits\n",
121 np2->full_name); 122 np2->full_name);
123 of_node_put(np2);
122 return -ENODEV; 124 return -ENODEV;
123 } 125 }
124 } 126 }
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 4d4d25efc1e1..908e8d486342 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -113,18 +113,18 @@ int mdio_mux_init(struct device *dev,
113 if (!parent_bus_node) 113 if (!parent_bus_node)
114 return -ENODEV; 114 return -ENODEV;
115 115
116 parent_bus = of_mdio_find_bus(parent_bus_node);
117 if (parent_bus == NULL) {
118 ret_val = -EPROBE_DEFER;
119 goto err_parent_bus;
120 }
121
122 pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL); 116 pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
123 if (pb == NULL) { 117 if (pb == NULL) {
124 ret_val = -ENOMEM; 118 ret_val = -ENOMEM;
125 goto err_parent_bus; 119 goto err_parent_bus;
126 } 120 }
127 121
122 parent_bus = of_mdio_find_bus(parent_bus_node);
123 if (parent_bus == NULL) {
124 ret_val = -EPROBE_DEFER;
125 goto err_parent_bus;
126 }
127
128 pb->switch_data = data; 128 pb->switch_data = data;
129 pb->switch_fn = switch_fn; 129 pb->switch_fn = switch_fn;
130 pb->current_child = -1; 130 pb->current_child = -1;
@@ -144,6 +144,7 @@ int mdio_mux_init(struct device *dev,
144 dev_err(dev, 144 dev_err(dev,
145 "Error: Failed to allocate memory for child\n"); 145 "Error: Failed to allocate memory for child\n");
146 ret_val = -ENOMEM; 146 ret_val = -ENOMEM;
147 of_node_put(child_bus_node);
147 break; 148 break;
148 } 149 }
149 cb->bus_number = v; 150 cb->bus_number = v;
@@ -173,6 +174,10 @@ int mdio_mux_init(struct device *dev,
173 dev_info(dev, "Version " DRV_VERSION "\n"); 174 dev_info(dev, "Version " DRV_VERSION "\n");
174 return 0; 175 return 0;
175 } 176 }
177
178 /* balance the reference of_mdio_find_bus() took */
179 put_device(&pb->mii_bus->dev);
180
176err_parent_bus: 181err_parent_bus:
177 of_node_put(parent_bus_node); 182 of_node_put(parent_bus_node);
178 return ret_val; 183 return ret_val;
@@ -189,6 +194,9 @@ void mdio_mux_uninit(void *mux_handle)
189 mdiobus_free(cb->mii_bus); 194 mdiobus_free(cb->mii_bus);
190 cb = cb->next; 195 cb = cb->next;
191 } 196 }
197
198 /* balance the reference of_mdio_find_bus() in mdio_mux_init() took */
199 put_device(&pb->mii_bus->dev);
192} 200}
193EXPORT_SYMBOL_GPL(mdio_mux_uninit); 201EXPORT_SYMBOL_GPL(mdio_mux_uninit);
194 202
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 02a4615b65f8..12f44c53cc8e 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -167,7 +167,9 @@ static int of_mdio_bus_match(struct device *dev, const void *mdio_bus_np)
167 * of_mdio_find_bus - Given an mii_bus node, find the mii_bus. 167 * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
168 * @mdio_bus_np: Pointer to the mii_bus. 168 * @mdio_bus_np: Pointer to the mii_bus.
169 * 169 *
170 * Returns a pointer to the mii_bus, or NULL if none found. 170 * Returns a reference to the mii_bus, or NULL if none found. The
171 * embedded struct device will have its reference count incremented,
172 * and this must be put once the bus is finished with.
171 * 173 *
172 * Because the association of a device_node and mii_bus is made via 174 * Because the association of a device_node and mii_bus is made via
173 * of_mdiobus_register(), the mii_bus cannot be found before it is 175 * of_mdiobus_register(), the mii_bus cannot be found before it is
@@ -234,15 +236,18 @@ static inline void of_mdiobus_link_phydev(struct mii_bus *mdio,
234#endif 236#endif
235 237
236/** 238/**
237 * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus 239 * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
238 * @bus: target mii_bus 240 * @bus: target mii_bus
241 * @owner: module containing bus accessor functions
239 * 242 *
240 * Description: Called by a bus driver to bring up all the PHYs 243 * Description: Called by a bus driver to bring up all the PHYs
241 * on a given bus, and attach them to the bus. 244 * on a given bus, and attach them to the bus. Drivers should use
245 * mdiobus_register() rather than __mdiobus_register() unless they
246 * need to pass a specific owner module.
242 * 247 *
243 * Returns 0 on success or < 0 on error. 248 * Returns 0 on success or < 0 on error.
244 */ 249 */
245int mdiobus_register(struct mii_bus *bus) 250int __mdiobus_register(struct mii_bus *bus, struct module *owner)
246{ 251{
247 int i, err; 252 int i, err;
248 253
@@ -253,6 +258,7 @@ int mdiobus_register(struct mii_bus *bus)
253 BUG_ON(bus->state != MDIOBUS_ALLOCATED && 258 BUG_ON(bus->state != MDIOBUS_ALLOCATED &&
254 bus->state != MDIOBUS_UNREGISTERED); 259 bus->state != MDIOBUS_UNREGISTERED);
255 260
261 bus->owner = owner;
256 bus->dev.parent = bus->parent; 262 bus->dev.parent = bus->parent;
257 bus->dev.class = &mdio_bus_class; 263 bus->dev.class = &mdio_bus_class;
258 bus->dev.groups = NULL; 264 bus->dev.groups = NULL;
@@ -288,13 +294,16 @@ int mdiobus_register(struct mii_bus *bus)
288 294
289error: 295error:
290 while (--i >= 0) { 296 while (--i >= 0) {
291 if (bus->phy_map[i]) 297 struct phy_device *phydev = bus->phy_map[i];
292 device_unregister(&bus->phy_map[i]->dev); 298 if (phydev) {
299 phy_device_remove(phydev);
300 phy_device_free(phydev);
301 }
293 } 302 }
294 device_del(&bus->dev); 303 device_del(&bus->dev);
295 return err; 304 return err;
296} 305}
297EXPORT_SYMBOL(mdiobus_register); 306EXPORT_SYMBOL(__mdiobus_register);
298 307
299void mdiobus_unregister(struct mii_bus *bus) 308void mdiobus_unregister(struct mii_bus *bus)
300{ 309{
@@ -304,9 +313,11 @@ void mdiobus_unregister(struct mii_bus *bus)
304 bus->state = MDIOBUS_UNREGISTERED; 313 bus->state = MDIOBUS_UNREGISTERED;
305 314
306 for (i = 0; i < PHY_MAX_ADDR; i++) { 315 for (i = 0; i < PHY_MAX_ADDR; i++) {
307 if (bus->phy_map[i]) 316 struct phy_device *phydev = bus->phy_map[i];
308 device_unregister(&bus->phy_map[i]->dev); 317 if (phydev) {
309 bus->phy_map[i] = NULL; 318 phy_device_remove(phydev);
319 phy_device_free(phydev);
320 }
310 } 321 }
311 device_del(&bus->dev); 322 device_del(&bus->dev);
312} 323}
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 499185eaf413..cf6312fafea5 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -514,6 +514,27 @@ static int ksz8873mll_read_status(struct phy_device *phydev)
514 return 0; 514 return 0;
515} 515}
516 516
517static int ksz9031_read_status(struct phy_device *phydev)
518{
519 int err;
520 int regval;
521
522 err = genphy_read_status(phydev);
523 if (err)
524 return err;
525
526 /* Make sure the PHY is not broken. Read idle error count,
527 * and reset the PHY if it is maxed out.
528 */
529 regval = phy_read(phydev, MII_STAT1000);
530 if ((regval & 0xFF) == 0xFF) {
531 phy_init_hw(phydev);
532 phydev->link = 0;
533 }
534
535 return 0;
536}
537
517static int ksz8873mll_config_aneg(struct phy_device *phydev) 538static int ksz8873mll_config_aneg(struct phy_device *phydev)
518{ 539{
519 return 0; 540 return 0;
@@ -772,7 +793,7 @@ static struct phy_driver ksphy_driver[] = {
772 .driver_data = &ksz9021_type, 793 .driver_data = &ksz9021_type,
773 .config_init = ksz9031_config_init, 794 .config_init = ksz9031_config_init,
774 .config_aneg = genphy_config_aneg, 795 .config_aneg = genphy_config_aneg,
775 .read_status = genphy_read_status, 796 .read_status = ksz9031_read_status,
776 .ack_interrupt = kszphy_ack_interrupt, 797 .ack_interrupt = kszphy_ack_interrupt,
777 .config_intr = kszphy_config_intr, 798 .config_intr = kszphy_config_intr,
778 .suspend = genphy_suspend, 799 .suspend = genphy_suspend,
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c0f211127274..f761288abe66 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -384,6 +384,24 @@ int phy_device_register(struct phy_device *phydev)
384EXPORT_SYMBOL(phy_device_register); 384EXPORT_SYMBOL(phy_device_register);
385 385
386/** 386/**
387 * phy_device_remove - Remove a previously registered phy device from the MDIO bus
388 * @phydev: phy_device structure to remove
389 *
390 * This doesn't free the phy_device itself, it merely reverses the effects
391 * of phy_device_register(). Use phy_device_free() to free the device
392 * after calling this function.
393 */
394void phy_device_remove(struct phy_device *phydev)
395{
396 struct mii_bus *bus = phydev->bus;
397 int addr = phydev->addr;
398
399 device_del(&phydev->dev);
400 bus->phy_map[addr] = NULL;
401}
402EXPORT_SYMBOL(phy_device_remove);
403
404/**
387 * phy_find_first - finds the first PHY device on the bus 405 * phy_find_first - finds the first PHY device on the bus
388 * @bus: the target MII bus 406 * @bus: the target MII bus
389 */ 407 */
@@ -578,14 +596,22 @@ EXPORT_SYMBOL(phy_init_hw);
578 * generic driver is used. The phy_device is given a ptr to 596 * generic driver is used. The phy_device is given a ptr to
579 * the attaching device, and given a callback for link status 597 * the attaching device, and given a callback for link status
580 * change. The phy_device is returned to the attaching driver. 598 * change. The phy_device is returned to the attaching driver.
599 * This function takes a reference on the phy device.
581 */ 600 */
582int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, 601int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
583 u32 flags, phy_interface_t interface) 602 u32 flags, phy_interface_t interface)
584{ 603{
604 struct mii_bus *bus = phydev->bus;
585 struct device *d = &phydev->dev; 605 struct device *d = &phydev->dev;
586 struct module *bus_module;
587 int err; 606 int err;
588 607
608 if (!try_module_get(bus->owner)) {
609 dev_err(&dev->dev, "failed to get the bus module\n");
610 return -EIO;
611 }
612
613 get_device(d);
614
589 /* Assume that if there is no driver, that it doesn't 615 /* Assume that if there is no driver, that it doesn't
590 * exist, and we should use the genphy driver. 616 * exist, and we should use the genphy driver.
591 */ 617 */
@@ -600,20 +626,13 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
600 err = device_bind_driver(d); 626 err = device_bind_driver(d);
601 627
602 if (err) 628 if (err)
603 return err; 629 goto error;
604 } 630 }
605 631
606 if (phydev->attached_dev) { 632 if (phydev->attached_dev) {
607 dev_err(&dev->dev, "PHY already attached\n"); 633 dev_err(&dev->dev, "PHY already attached\n");
608 return -EBUSY; 634 err = -EBUSY;
609 } 635 goto error;
610
611 /* Increment the bus module reference count */
612 bus_module = phydev->bus->dev.driver ?
613 phydev->bus->dev.driver->owner : NULL;
614 if (!try_module_get(bus_module)) {
615 dev_err(&dev->dev, "failed to get the bus module\n");
616 return -EIO;
617 } 636 }
618 637
619 phydev->attached_dev = dev; 638 phydev->attached_dev = dev;
@@ -636,6 +655,11 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
636 phy_resume(phydev); 655 phy_resume(phydev);
637 656
638 return err; 657 return err;
658
659error:
660 put_device(d);
661 module_put(bus->owner);
662 return err;
639} 663}
640EXPORT_SYMBOL(phy_attach_direct); 664EXPORT_SYMBOL(phy_attach_direct);
641 665
@@ -677,14 +701,15 @@ EXPORT_SYMBOL(phy_attach);
677/** 701/**
678 * phy_detach - detach a PHY device from its network device 702 * phy_detach - detach a PHY device from its network device
679 * @phydev: target phy_device struct 703 * @phydev: target phy_device struct
704 *
705 * This detaches the phy device from its network device and the phy
706 * driver, and drops the reference count taken in phy_attach_direct().
680 */ 707 */
681void phy_detach(struct phy_device *phydev) 708void phy_detach(struct phy_device *phydev)
682{ 709{
710 struct mii_bus *bus;
683 int i; 711 int i;
684 712
685 if (phydev->bus->dev.driver)
686 module_put(phydev->bus->dev.driver->owner);
687
688 phydev->attached_dev->phydev = NULL; 713 phydev->attached_dev->phydev = NULL;
689 phydev->attached_dev = NULL; 714 phydev->attached_dev = NULL;
690 phy_suspend(phydev); 715 phy_suspend(phydev);
@@ -700,6 +725,15 @@ void phy_detach(struct phy_device *phydev)
700 break; 725 break;
701 } 726 }
702 } 727 }
728
729 /*
730 * The phydev might go away on the put_device() below, so avoid
731 * a use-after-free bug by reading the underlying bus first.
732 */
733 bus = phydev->bus;
734
735 put_device(&phydev->dev);
736 module_put(bus->owner);
703} 737}
704EXPORT_SYMBOL(phy_detach); 738EXPORT_SYMBOL(phy_detach);
705 739
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 70b08958763a..dc2da8770918 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -43,16 +43,25 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
43 43
44static int smsc_phy_config_init(struct phy_device *phydev) 44static int smsc_phy_config_init(struct phy_device *phydev)
45{ 45{
46 int __maybe_unused len;
47 struct device *dev __maybe_unused = &phydev->dev;
48 struct device_node *of_node __maybe_unused = dev->of_node;
46 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); 49 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
50 int enable_energy = 1;
47 51
48 if (rc < 0) 52 if (rc < 0)
49 return rc; 53 return rc;
50 54
51 /* Enable energy detect mode for this SMSC Transceivers */ 55 if (of_find_property(of_node, "smsc,disable-energy-detect", &len))
52 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, 56 enable_energy = 0;
53 rc | MII_LAN83C185_EDPWRDOWN); 57
54 if (rc < 0) 58 if (enable_energy) {
55 return rc; 59 /* Enable energy detect mode for this SMSC Transceivers */
60 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
61 rc | MII_LAN83C185_EDPWRDOWN);
62 if (rc < 0)
63 return rc;
64 }
56 65
57 return smsc_phy_ack_interrupt(phydev); 66 return smsc_phy_ack_interrupt(phydev);
58} 67}
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 17cad185169d..76cad712ddb2 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -66,7 +66,6 @@
66#define PHY_ID_VSC8244 0x000fc6c0 66#define PHY_ID_VSC8244 0x000fc6c0
67#define PHY_ID_VSC8514 0x00070670 67#define PHY_ID_VSC8514 0x00070670
68#define PHY_ID_VSC8574 0x000704a0 68#define PHY_ID_VSC8574 0x000704a0
69#define PHY_ID_VSC8641 0x00070431
70#define PHY_ID_VSC8662 0x00070660 69#define PHY_ID_VSC8662 0x00070660
71#define PHY_ID_VSC8221 0x000fc550 70#define PHY_ID_VSC8221 0x000fc550
72#define PHY_ID_VSC8211 0x000fc4b0 71#define PHY_ID_VSC8211 0x000fc4b0
@@ -273,18 +272,6 @@ static struct phy_driver vsc82xx_driver[] = {
273 .config_intr = &vsc82xx_config_intr, 272 .config_intr = &vsc82xx_config_intr,
274 .driver = { .owner = THIS_MODULE,}, 273 .driver = { .owner = THIS_MODULE,},
275}, { 274}, {
276 .phy_id = PHY_ID_VSC8641,
277 .name = "Vitesse VSC8641",
278 .phy_id_mask = 0x000ffff0,
279 .features = PHY_GBIT_FEATURES,
280 .flags = PHY_HAS_INTERRUPT,
281 .config_init = &vsc824x_config_init,
282 .config_aneg = &vsc82x4_config_aneg,
283 .read_status = &genphy_read_status,
284 .ack_interrupt = &vsc824x_ack_interrupt,
285 .config_intr = &vsc82xx_config_intr,
286 .driver = { .owner = THIS_MODULE,},
287}, {
288 .phy_id = PHY_ID_VSC8662, 275 .phy_id = PHY_ID_VSC8662,
289 .name = "Vitesse VSC8662", 276 .name = "Vitesse VSC8662",
290 .phy_id_mask = 0x000ffff0, 277 .phy_id_mask = 0x000ffff0,
@@ -331,7 +318,6 @@ static struct mdio_device_id __maybe_unused vitesse_tbl[] = {
331 { PHY_ID_VSC8244, 0x000fffc0 }, 318 { PHY_ID_VSC8244, 0x000fffc0 },
332 { PHY_ID_VSC8514, 0x000ffff0 }, 319 { PHY_ID_VSC8514, 0x000ffff0 },
333 { PHY_ID_VSC8574, 0x000ffff0 }, 320 { PHY_ID_VSC8574, 0x000ffff0 },
334 { PHY_ID_VSC8641, 0x000ffff0 },
335 { PHY_ID_VSC8662, 0x000ffff0 }, 321 { PHY_ID_VSC8662, 0x000ffff0 },
336 { PHY_ID_VSC8221, 0x000ffff0 }, 322 { PHY_ID_VSC8221, 0x000ffff0 },
337 { PHY_ID_VSC8211, 0x000ffff0 }, 323 { PHY_ID_VSC8211, 0x000ffff0 },
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 0481daf9201a..ed00446759b2 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2755,6 +2755,7 @@ static struct ppp *ppp_create_interface(struct net *net, int unit,
2755 */ 2755 */
2756 dev_net_set(dev, net); 2756 dev_net_set(dev, net);
2757 2757
2758 rtnl_lock();
2758 mutex_lock(&pn->all_ppp_mutex); 2759 mutex_lock(&pn->all_ppp_mutex);
2759 2760
2760 if (unit < 0) { 2761 if (unit < 0) {
@@ -2785,7 +2786,7 @@ static struct ppp *ppp_create_interface(struct net *net, int unit,
2785 ppp->file.index = unit; 2786 ppp->file.index = unit;
2786 sprintf(dev->name, "ppp%d", unit); 2787 sprintf(dev->name, "ppp%d", unit);
2787 2788
2788 ret = register_netdev(dev); 2789 ret = register_netdevice(dev);
2789 if (ret != 0) { 2790 if (ret != 0) {
2790 unit_put(&pn->units_idr, unit); 2791 unit_put(&pn->units_idr, unit);
2791 netdev_err(ppp->dev, "PPP: couldn't register device %s (%d)\n", 2792 netdev_err(ppp->dev, "PPP: couldn't register device %s (%d)\n",
@@ -2797,6 +2798,7 @@ static struct ppp *ppp_create_interface(struct net *net, int unit,
2797 2798
2798 atomic_inc(&ppp_unit_count); 2799 atomic_inc(&ppp_unit_count);
2799 mutex_unlock(&pn->all_ppp_mutex); 2800 mutex_unlock(&pn->all_ppp_mutex);
2801 rtnl_unlock();
2800 2802
2801 *retp = 0; 2803 *retp = 0;
2802 return ppp; 2804 return ppp;
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index 3837ae344f63..5e0b43283bce 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -313,7 +313,6 @@ static void pppoe_flush_dev(struct net_device *dev)
313 if (po->pppoe_dev == dev && 313 if (po->pppoe_dev == dev &&
314 sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) { 314 sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) {
315 pppox_unbind_sock(sk); 315 pppox_unbind_sock(sk);
316 sk->sk_state = PPPOX_ZOMBIE;
317 sk->sk_state_change(sk); 316 sk->sk_state_change(sk);
318 po->pppoe_dev = NULL; 317 po->pppoe_dev = NULL;
319 dev_put(dev); 318 dev_put(dev);
@@ -590,7 +589,7 @@ static int pppoe_release(struct socket *sock)
590 589
591 po = pppox_sk(sk); 590 po = pppox_sk(sk);
592 591
593 if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) { 592 if (po->pppoe_dev) {
594 dev_put(po->pppoe_dev); 593 dev_put(po->pppoe_dev);
595 po->pppoe_dev = NULL; 594 po->pppoe_dev = NULL;
596 } 595 }
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 1610b79ae386..e66805eeffb4 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -164,6 +164,7 @@ config USB_NET_AX8817X
164 * Aten UC210T 164 * Aten UC210T
165 * ASIX AX88172 165 * ASIX AX88172
166 * Billionton Systems, USB2AR 166 * Billionton Systems, USB2AR
167 * Billionton Systems, GUSB2AM-1G-B
167 * Buffalo LUA-U2-KTX 168 * Buffalo LUA-U2-KTX
168 * Corega FEther USB2-TX 169 * Corega FEther USB2-TX
169 * D-Link DUB-E100 170 * D-Link DUB-E100
@@ -583,4 +584,15 @@ config USB_VL600
583 584
584 http://ubuntuforums.org/showpost.php?p=10589647&postcount=17 585 http://ubuntuforums.org/showpost.php?p=10589647&postcount=17
585 586
587config USB_NET_CH9200
588 tristate "QingHeng CH9200 USB ethernet support"
589 depends on USB_USBNET
590 select MII
591 help
592 Choose this option if you have a USB ethernet adapter with a QinHeng
593 CH9200 chipset.
594
595 To compile this driver as a module, choose M here: the
596 module will be called ch9200.
597
586endif # USB_NET_DRIVERS 598endif # USB_NET_DRIVERS
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index cf6a0e610a7f..b5f04068dbe4 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -38,4 +38,4 @@ obj-$(CONFIG_USB_NET_HUAWEI_CDC_NCM) += huawei_cdc_ncm.o
38obj-$(CONFIG_USB_VL600) += lg-vl600.o 38obj-$(CONFIG_USB_VL600) += lg-vl600.o
39obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o 39obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o
40obj-$(CONFIG_USB_NET_CDC_MBIM) += cdc_mbim.o 40obj-$(CONFIG_USB_NET_CDC_MBIM) += cdc_mbim.o
41 41obj-$(CONFIG_USB_NET_CH9200) += ch9200.o
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 75d6f26729a3..079069a060a6 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -91,8 +91,10 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
91 } 91 }
92 rx->ax_skb = netdev_alloc_skb_ip_align(dev->net, 92 rx->ax_skb = netdev_alloc_skb_ip_align(dev->net,
93 rx->size); 93 rx->size);
94 if (!rx->ax_skb) 94 if (!rx->ax_skb) {
95 rx->size = 0;
95 return 0; 96 return 0;
97 }
96 } 98 }
97 99
98 if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) { 100 if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) {
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 1173a24feda3..5cabefc23494 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -959,6 +959,10 @@ static const struct usb_device_id products [] = {
959 USB_DEVICE (0x08dd, 0x90ff), 959 USB_DEVICE (0x08dd, 0x90ff),
960 .driver_info = (unsigned long) &ax8817x_info, 960 .driver_info = (unsigned long) &ax8817x_info,
961}, { 961}, {
962 // Billionton Systems, GUSB2AM-1G-B
963 USB_DEVICE(0x08dd, 0x0114),
964 .driver_info = (unsigned long) &ax88178_info,
965}, {
962 // ATEN UC210T 966 // ATEN UC210T
963 USB_DEVICE (0x0557, 0x2009), 967 USB_DEVICE (0x0557, 0x2009),
964 .driver_info = (unsigned long) &ax8817x_info, 968 .driver_info = (unsigned long) &ax8817x_info,
diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c
new file mode 100644
index 000000000000..5e151e6a3e09
--- /dev/null
+++ b/drivers/net/usb/ch9200.c
@@ -0,0 +1,432 @@
1/*
2 * USB 10M/100M ethernet adapter
3 *
4 * This file is licensed under the terms of the GNU General Public License
5 * version 2. This program is licensed "as is" without any warranty of any
6 * kind, whether express or implied
7 *
8 */
9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/stddef.h>
14#include <linux/init.h>
15#include <linux/netdevice.h>
16#include <linux/etherdevice.h>
17#include <linux/ethtool.h>
18#include <linux/mii.h>
19#include <linux/usb.h>
20#include <linux/crc32.h>
21#include <linux/usb/usbnet.h>
22#include <linux/slab.h>
23
24#define CH9200_VID 0x1A86
25#define CH9200_PID_E092 0xE092
26
27#define CTRL_TIMEOUT_MS 1000
28
29#define CONTROL_TIMEOUT_MS 1000
30
31#define REQUEST_READ 0x0E
32#define REQUEST_WRITE 0x0F
33
34/* Address space:
35 * 00-63 : MII
36 * 64-128: MAC
37 *
38 * Note: all accesses must be 16-bit
39 */
40
41#define MAC_REG_CTRL 64
42#define MAC_REG_STATUS 66
43#define MAC_REG_INTERRUPT_MASK 68
44#define MAC_REG_PHY_COMMAND 70
45#define MAC_REG_PHY_DATA 72
46#define MAC_REG_STATION_L 74
47#define MAC_REG_STATION_M 76
48#define MAC_REG_STATION_H 78
49#define MAC_REG_HASH_L 80
50#define MAC_REG_HASH_M1 82
51#define MAC_REG_HASH_M2 84
52#define MAC_REG_HASH_H 86
53#define MAC_REG_THRESHOLD 88
54#define MAC_REG_FIFO_DEPTH 90
55#define MAC_REG_PAUSE 92
56#define MAC_REG_FLOW_CONTROL 94
57
58/* Control register bits
59 *
60 * Note: bits 13 and 15 are reserved
61 */
62#define LOOPBACK (0x01 << 14)
63#define BASE100X (0x01 << 12)
64#define MBPS_10 (0x01 << 11)
65#define DUPLEX_MODE (0x01 << 10)
66#define PAUSE_FRAME (0x01 << 9)
67#define PROMISCUOUS (0x01 << 8)
68#define MULTICAST (0x01 << 7)
69#define BROADCAST (0x01 << 6)
70#define HASH (0x01 << 5)
71#define APPEND_PAD (0x01 << 4)
72#define APPEND_CRC (0x01 << 3)
73#define TRANSMITTER_ACTION (0x01 << 2)
74#define RECEIVER_ACTION (0x01 << 1)
75#define DMA_ACTION (0x01 << 0)
76
77/* Status register bits
78 *
79 * Note: bits 7-15 are reserved
80 */
81#define ALIGNMENT (0x01 << 6)
82#define FIFO_OVER_RUN (0x01 << 5)
83#define FIFO_UNDER_RUN (0x01 << 4)
84#define RX_ERROR (0x01 << 3)
85#define RX_COMPLETE (0x01 << 2)
86#define TX_ERROR (0x01 << 1)
87#define TX_COMPLETE (0x01 << 0)
88
89/* FIFO depth register bits
90 *
91 * Note: bits 6 and 14 are reserved
92 */
93
94#define ETH_TXBD (0x01 << 15)
95#define ETN_TX_FIFO_DEPTH (0x01 << 8)
96#define ETH_RXBD (0x01 << 7)
97#define ETH_RX_FIFO_DEPTH (0x01 << 0)
98
99static int control_read(struct usbnet *dev,
100 unsigned char request, unsigned short value,
101 unsigned short index, void *data, unsigned short size,
102 int timeout)
103{
104 unsigned char *buf = NULL;
105 unsigned char request_type;
106 int err = 0;
107
108 if (request == REQUEST_READ)
109 request_type = (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER);
110 else
111 request_type = (USB_DIR_IN | USB_TYPE_VENDOR |
112 USB_RECIP_DEVICE);
113
114 netdev_dbg(dev->net, "Control_read() index=0x%02x size=%d\n",
115 index, size);
116
117 buf = kmalloc(size, GFP_KERNEL);
118 if (!buf) {
119 err = -ENOMEM;
120 goto err_out;
121 }
122
123 err = usb_control_msg(dev->udev,
124 usb_rcvctrlpipe(dev->udev, 0),
125 request, request_type, value, index, buf, size,
126 timeout);
127 if (err == size)
128 memcpy(data, buf, size);
129 else if (err >= 0)
130 err = -EINVAL;
131 kfree(buf);
132
133 return err;
134
135err_out:
136 return err;
137}
138
139static int control_write(struct usbnet *dev, unsigned char request,
140 unsigned short value, unsigned short index,
141 void *data, unsigned short size, int timeout)
142{
143 unsigned char *buf = NULL;
144 unsigned char request_type;
145 int err = 0;
146
147 if (request == REQUEST_WRITE)
148 request_type = (USB_DIR_OUT | USB_TYPE_VENDOR |
149 USB_RECIP_OTHER);
150 else
151 request_type = (USB_DIR_OUT | USB_TYPE_VENDOR |
152 USB_RECIP_DEVICE);
153
154 netdev_dbg(dev->net, "Control_write() index=0x%02x size=%d\n",
155 index, size);
156
157 if (data) {
158 buf = kmalloc(size, GFP_KERNEL);
159 if (!buf) {
160 err = -ENOMEM;
161 goto err_out;
162 }
163 memcpy(buf, data, size);
164 }
165
166 err = usb_control_msg(dev->udev,
167 usb_sndctrlpipe(dev->udev, 0),
168 request, request_type, value, index, buf, size,
169 timeout);
170 if (err >= 0 && err < size)
171 err = -EINVAL;
172 kfree(buf);
173
174 return 0;
175
176err_out:
177 return err;
178}
179
180static int ch9200_mdio_read(struct net_device *netdev, int phy_id, int loc)
181{
182 struct usbnet *dev = netdev_priv(netdev);
183 unsigned char buff[2];
184
185 netdev_dbg(netdev, "ch9200_mdio_read phy_id:%02x loc:%02x\n",
186 phy_id, loc);
187
188 if (phy_id != 0)
189 return -ENODEV;
190
191 control_read(dev, REQUEST_READ, 0, loc * 2, buff, 0x02,
192 CONTROL_TIMEOUT_MS);
193
194 return (buff[0] | buff[1] << 8);
195}
196
197static void ch9200_mdio_write(struct net_device *netdev,
198 int phy_id, int loc, int val)
199{
200 struct usbnet *dev = netdev_priv(netdev);
201 unsigned char buff[2];
202
203 netdev_dbg(netdev, "ch9200_mdio_write() phy_id=%02x loc:%02x\n",
204 phy_id, loc);
205
206 if (phy_id != 0)
207 return;
208
209 buff[0] = (unsigned char)val;
210 buff[1] = (unsigned char)(val >> 8);
211
212 control_write(dev, REQUEST_WRITE, 0, loc * 2, buff, 0x02,
213 CONTROL_TIMEOUT_MS);
214}
215
216static int ch9200_link_reset(struct usbnet *dev)
217{
218 struct ethtool_cmd ecmd;
219
220 mii_check_media(&dev->mii, 1, 1);
221 mii_ethtool_gset(&dev->mii, &ecmd);
222
223 netdev_dbg(dev->net, "link_reset() speed:%d duplex:%d\n",
224 ecmd.speed, ecmd.duplex);
225
226 return 0;
227}
228
229static void ch9200_status(struct usbnet *dev, struct urb *urb)
230{
231 int link;
232 unsigned char *buf;
233
234 if (urb->actual_length < 16)
235 return;
236
237 buf = urb->transfer_buffer;
238 link = !!(buf[0] & 0x01);
239
240 if (link) {
241 netif_carrier_on(dev->net);
242 usbnet_defer_kevent(dev, EVENT_LINK_RESET);
243 } else {
244 netif_carrier_off(dev->net);
245 }
246}
247
248static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
249 gfp_t flags)
250{
251 int i = 0;
252 int len = 0;
253 int tx_overhead = 0;
254
255 tx_overhead = 0x40;
256
257 len = skb->len;
258 if (skb_headroom(skb) < tx_overhead) {
259 struct sk_buff *skb2;
260
261 skb2 = skb_copy_expand(skb, tx_overhead, 0, flags);
262 dev_kfree_skb_any(skb);
263 skb = skb2;
264 if (!skb)
265 return NULL;
266 }
267
268 __skb_push(skb, tx_overhead);
269 /* usbnet adds padding if length is a multiple of packet size
270 * if so, adjust length value in header
271 */
272 if ((skb->len % dev->maxpacket) == 0)
273 len++;
274
275 skb->data[0] = len;
276 skb->data[1] = len >> 8;
277 skb->data[2] = 0x00;
278 skb->data[3] = 0x80;
279
280 for (i = 4; i < 48; i++)
281 skb->data[i] = 0x00;
282
283 skb->data[48] = len;
284 skb->data[49] = len >> 8;
285 skb->data[50] = 0x00;
286 skb->data[51] = 0x80;
287
288 for (i = 52; i < 64; i++)
289 skb->data[i] = 0x00;
290
291 return skb;
292}
293
294static int ch9200_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
295{
296 int len = 0;
297 int rx_overhead = 0;
298
299 rx_overhead = 64;
300
301 if (unlikely(skb->len < rx_overhead)) {
302 dev_err(&dev->udev->dev, "unexpected tiny rx frame\n");
303 return 0;
304 }
305
306 len = (skb->data[skb->len - 16] | skb->data[skb->len - 15] << 8);
307 skb_trim(skb, len);
308
309 return 1;
310}
311
312static int get_mac_address(struct usbnet *dev, unsigned char *data)
313{
314 int err = 0;
315 unsigned char mac_addr[0x06];
316 int rd_mac_len = 0;
317
318 netdev_dbg(dev->net, "get_mac_address:\n\tusbnet VID:%0x PID:%0x\n",
319 dev->udev->descriptor.idVendor,
320 dev->udev->descriptor.idProduct);
321
322 memset(mac_addr, 0, sizeof(mac_addr));
323 rd_mac_len = control_read(dev, REQUEST_READ, 0,
324 MAC_REG_STATION_L, mac_addr, 0x02,
325 CONTROL_TIMEOUT_MS);
326 rd_mac_len += control_read(dev, REQUEST_READ, 0, MAC_REG_STATION_M,
327 mac_addr + 2, 0x02, CONTROL_TIMEOUT_MS);
328 rd_mac_len += control_read(dev, REQUEST_READ, 0, MAC_REG_STATION_H,
329 mac_addr + 4, 0x02, CONTROL_TIMEOUT_MS);
330 if (rd_mac_len != ETH_ALEN)
331 err = -EINVAL;
332
333 data[0] = mac_addr[5];
334 data[1] = mac_addr[4];
335 data[2] = mac_addr[3];
336 data[3] = mac_addr[2];
337 data[4] = mac_addr[1];
338 data[5] = mac_addr[0];
339
340 return err;
341}
342
343static int ch9200_bind(struct usbnet *dev, struct usb_interface *intf)
344{
345 int retval = 0;
346 unsigned char data[2];
347
348 retval = usbnet_get_endpoints(dev, intf);
349 if (retval)
350 return retval;
351
352 dev->mii.dev = dev->net;
353 dev->mii.mdio_read = ch9200_mdio_read;
354 dev->mii.mdio_write = ch9200_mdio_write;
355 dev->mii.reg_num_mask = 0x1f;
356
357 dev->mii.phy_id_mask = 0x1f;
358
359 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
360 dev->rx_urb_size = 24 * 64 + 16;
361 mii_nway_restart(&dev->mii);
362
363 data[0] = 0x01;
364 data[1] = 0x0F;
365 retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_THRESHOLD, data,
366 0x02, CONTROL_TIMEOUT_MS);
367
368 data[0] = 0xA0;
369 data[1] = 0x90;
370 retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_FIFO_DEPTH, data,
371 0x02, CONTROL_TIMEOUT_MS);
372
373 data[0] = 0x30;
374 data[1] = 0x00;
375 retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_PAUSE, data,
376 0x02, CONTROL_TIMEOUT_MS);
377
378 data[0] = 0x17;
379 data[1] = 0xD8;
380 retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_FLOW_CONTROL,
381 data, 0x02, CONTROL_TIMEOUT_MS);
382
383 /* Undocumented register */
384 data[0] = 0x01;
385 data[1] = 0x00;
386 retval = control_write(dev, REQUEST_WRITE, 0, 254, data, 0x02,
387 CONTROL_TIMEOUT_MS);
388
389 data[0] = 0x5F;
390 data[1] = 0x0D;
391 retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_CTRL, data, 0x02,
392 CONTROL_TIMEOUT_MS);
393
394 retval = get_mac_address(dev, dev->net->dev_addr);
395
396 return retval;
397}
398
399static const struct driver_info ch9200_info = {
400 .description = "CH9200 USB to Network Adaptor",
401 .flags = FLAG_ETHER,
402 .bind = ch9200_bind,
403 .rx_fixup = ch9200_rx_fixup,
404 .tx_fixup = ch9200_tx_fixup,
405 .status = ch9200_status,
406 .link_reset = ch9200_link_reset,
407 .reset = ch9200_link_reset,
408};
409
410static const struct usb_device_id ch9200_products[] = {
411 {
412 USB_DEVICE(0x1A86, 0xE092),
413 .driver_info = (unsigned long)&ch9200_info,
414 },
415 {},
416};
417
418MODULE_DEVICE_TABLE(usb, ch9200_products);
419
420static struct usb_driver ch9200_driver = {
421 .name = "ch9200",
422 .id_table = ch9200_products,
423 .probe = usbnet_probe,
424 .disconnect = usbnet_disconnect,
425 .suspend = usbnet_suspend,
426 .resume = usbnet_resume,
427};
428
429module_usb_driver(ch9200_driver);
430
431MODULE_DESCRIPTION("QinHeng CH9200 USB Network device");
432MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 355842b85ee9..2a7c1be23c4f 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -765,6 +765,10 @@ static const struct usb_device_id products[] = {
765 {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */ 765 {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */
766 {QMI_FIXED_INTF(0x1199, 0x9057, 8)}, 766 {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
767 {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */ 767 {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */
768 {QMI_FIXED_INTF(0x1199, 0x9070, 8)}, /* Sierra Wireless MC74xx/EM74xx */
769 {QMI_FIXED_INTF(0x1199, 0x9070, 10)}, /* Sierra Wireless MC74xx/EM74xx */
770 {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx/EM74xx */
771 {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx/EM74xx */
768 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ 772 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
769 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ 773 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
770 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ 774 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index e7094fbd7568..488c6f50df73 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -193,7 +193,8 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
193 .flowi4_oif = vrf_dev->ifindex, 193 .flowi4_oif = vrf_dev->ifindex,
194 .flowi4_iif = LOOPBACK_IFINDEX, 194 .flowi4_iif = LOOPBACK_IFINDEX,
195 .flowi4_tos = RT_TOS(ip4h->tos), 195 .flowi4_tos = RT_TOS(ip4h->tos),
196 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC, 196 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC |
197 FLOWI_FLAG_SKIP_NH_OIF,
197 .daddr = ip4h->daddr, 198 .daddr = ip4h->daddr,
198 }; 199 };
199 200
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index cf8b7f0473b3..c1587ece28cf 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2337,6 +2337,46 @@ static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
2337 return 0; 2337 return 0;
2338} 2338}
2339 2339
2340static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
2341 struct ip_tunnel_info *info,
2342 __be16 sport, __be16 dport)
2343{
2344 struct vxlan_dev *vxlan = netdev_priv(dev);
2345 struct rtable *rt;
2346 struct flowi4 fl4;
2347
2348 memset(&fl4, 0, sizeof(fl4));
2349 fl4.flowi4_tos = RT_TOS(info->key.tos);
2350 fl4.flowi4_mark = skb->mark;
2351 fl4.flowi4_proto = IPPROTO_UDP;
2352 fl4.daddr = info->key.u.ipv4.dst;
2353
2354 rt = ip_route_output_key(vxlan->net, &fl4);
2355 if (IS_ERR(rt))
2356 return PTR_ERR(rt);
2357 ip_rt_put(rt);
2358
2359 info->key.u.ipv4.src = fl4.saddr;
2360 info->key.tp_src = sport;
2361 info->key.tp_dst = dport;
2362 return 0;
2363}
2364
2365static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
2366{
2367 struct vxlan_dev *vxlan = netdev_priv(dev);
2368 struct ip_tunnel_info *info = skb_tunnel_info(skb);
2369 __be16 sport, dport;
2370
2371 sport = udp_flow_src_port(dev_net(dev), skb, vxlan->cfg.port_min,
2372 vxlan->cfg.port_max, true);
2373 dport = info->key.tp_dst ? : vxlan->cfg.dst_port;
2374
2375 if (ip_tunnel_info_af(info) == AF_INET)
2376 return egress_ipv4_tun_info(dev, skb, info, sport, dport);
2377 return -EINVAL;
2378}
2379
2340static const struct net_device_ops vxlan_netdev_ops = { 2380static const struct net_device_ops vxlan_netdev_ops = {
2341 .ndo_init = vxlan_init, 2381 .ndo_init = vxlan_init,
2342 .ndo_uninit = vxlan_uninit, 2382 .ndo_uninit = vxlan_uninit,
@@ -2351,6 +2391,7 @@ static const struct net_device_ops vxlan_netdev_ops = {
2351 .ndo_fdb_add = vxlan_fdb_add, 2391 .ndo_fdb_add = vxlan_fdb_add,
2352 .ndo_fdb_del = vxlan_fdb_delete, 2392 .ndo_fdb_del = vxlan_fdb_delete,
2353 .ndo_fdb_dump = vxlan_fdb_dump, 2393 .ndo_fdb_dump = vxlan_fdb_dump,
2394 .ndo_fill_metadata_dst = vxlan_fill_metadata_dst,
2354}; 2395};
2355 2396
2356/* Info for udev, that this is a virtual tunnel endpoint */ 2397/* Info for udev, that this is a virtual tunnel endpoint */
@@ -2392,10 +2433,6 @@ static void vxlan_setup(struct net_device *dev)
2392 2433
2393 eth_hw_addr_random(dev); 2434 eth_hw_addr_random(dev);
2394 ether_setup(dev); 2435 ether_setup(dev);
2395 if (vxlan->default_dst.remote_ip.sa.sa_family == AF_INET6)
2396 dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM;
2397 else
2398 dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM;
2399 2436
2400 dev->netdev_ops = &vxlan_netdev_ops; 2437 dev->netdev_ops = &vxlan_netdev_ops;
2401 dev->destructor = free_netdev; 2438 dev->destructor = free_netdev;
@@ -2640,8 +2677,11 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
2640 dst->remote_ip.sa.sa_family = AF_INET; 2677 dst->remote_ip.sa.sa_family = AF_INET;
2641 2678
2642 if (dst->remote_ip.sa.sa_family == AF_INET6 || 2679 if (dst->remote_ip.sa.sa_family == AF_INET6 ||
2643 vxlan->cfg.saddr.sa.sa_family == AF_INET6) 2680 vxlan->cfg.saddr.sa.sa_family == AF_INET6) {
2681 if (!IS_ENABLED(CONFIG_IPV6))
2682 return -EPFNOSUPPORT;
2644 use_ipv6 = true; 2683 use_ipv6 = true;
2684 }
2645 2685
2646 if (conf->remote_ifindex) { 2686 if (conf->remote_ifindex) {
2647 struct net_device *lowerdev 2687 struct net_device *lowerdev
@@ -2670,8 +2710,12 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
2670 2710
2671 dev->needed_headroom = lowerdev->hard_header_len + 2711 dev->needed_headroom = lowerdev->hard_header_len +
2672 (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); 2712 (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);
2673 } else if (use_ipv6) 2713 } else if (use_ipv6) {
2674 vxlan->flags |= VXLAN_F_IPV6; 2714 vxlan->flags |= VXLAN_F_IPV6;
2715 dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM;
2716 } else {
2717 dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM;
2718 }
2675 2719
2676 memcpy(&vxlan->cfg, conf, sizeof(*conf)); 2720 memcpy(&vxlan->cfg, conf, sizeof(*conf));
2677 if (!vxlan->cfg.dst_port) 2721 if (!vxlan->cfg.dst_port)
@@ -2742,11 +2786,10 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev,
2742 struct vxlan_config conf; 2786 struct vxlan_config conf;
2743 int err; 2787 int err;
2744 2788
2745 if (!data[IFLA_VXLAN_ID])
2746 return -EINVAL;
2747
2748 memset(&conf, 0, sizeof(conf)); 2789 memset(&conf, 0, sizeof(conf));
2749 conf.vni = nla_get_u32(data[IFLA_VXLAN_ID]); 2790
2791 if (data[IFLA_VXLAN_ID])
2792 conf.vni = nla_get_u32(data[IFLA_VXLAN_ID]);
2750 2793
2751 if (data[IFLA_VXLAN_GROUP]) { 2794 if (data[IFLA_VXLAN_GROUP]) {
2752 conf.remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]); 2795 conf.remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]);
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
index 23afcda2de96..678d72af4a9d 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -337,7 +337,7 @@ enum ath10k_hw_rate_cck {
337#define TARGET_10X_MAX_FRAG_ENTRIES 0 337#define TARGET_10X_MAX_FRAG_ENTRIES 0
338 338
339/* 10.2 parameters */ 339/* 10.2 parameters */
340#define TARGET_10_2_DMA_BURST_SIZE 1 340#define TARGET_10_2_DMA_BURST_SIZE 0
341 341
342/* Target specific defines for WMI-TLV firmware */ 342/* Target specific defines for WMI-TLV firmware */
343#define TARGET_TLV_NUM_VDEVS 4 343#define TARGET_TLV_NUM_VDEVS 4
@@ -391,7 +391,7 @@ enum ath10k_hw_rate_cck {
391 391
392#define TARGET_10_4_TX_DBG_LOG_SIZE 1024 392#define TARGET_10_4_TX_DBG_LOG_SIZE 1024
393#define TARGET_10_4_NUM_WDS_ENTRIES 32 393#define TARGET_10_4_NUM_WDS_ENTRIES 32
394#define TARGET_10_4_DMA_BURST_SIZE 1 394#define TARGET_10_4_DMA_BURST_SIZE 0
395#define TARGET_10_4_MAC_AGGR_DELIM 0 395#define TARGET_10_4_MAC_AGGR_DELIM 0
396#define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1 396#define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
397#define TARGET_10_4_VOW_CONFIG 0 397#define TARGET_10_4_VOW_CONFIG 0
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa4b13c..12241b1c57cd 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -715,6 +715,7 @@ static bool check_device_tree(struct ath6kl *ar)
715 board_filename, ret); 715 board_filename, ret);
716 continue; 716 continue;
717 } 717 }
718 of_node_put(node);
718 return true; 719 return true;
719 } 720 }
720 return false; 721 return false;
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 57f95f2dca5b..90eb75012e4f 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -880,6 +880,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
880 hw->max_rate_tries = 10; 880 hw->max_rate_tries = 10;
881 hw->sta_data_size = sizeof(struct ath_node); 881 hw->sta_data_size = sizeof(struct ath_node);
882 hw->vif_data_size = sizeof(struct ath_vif); 882 hw->vif_data_size = sizeof(struct ath_vif);
883 hw->extra_tx_headroom = 4;
883 884
884 hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; 885 hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1;
885 hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1; 886 hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1;
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 28490702124a..71d3e9adbf3c 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -120,6 +120,7 @@ MODULE_PARM_DESC(allhwsupport, "Enable support for all hardware (even it if over
120#ifdef CONFIG_B43_BCMA 120#ifdef CONFIG_B43_BCMA
121static const struct bcma_device_id b43_bcma_tbl[] = { 121static const struct bcma_device_id b43_bcma_tbl[] = {
122 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x11, BCMA_ANY_CLASS), 122 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x11, BCMA_ANY_CLASS),
123 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x15, BCMA_ANY_CLASS),
123 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x17, BCMA_ANY_CLASS), 124 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x17, BCMA_ANY_CLASS),
124 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x18, BCMA_ANY_CLASS), 125 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x18, BCMA_ANY_CLASS),
125 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x1C, BCMA_ANY_CLASS), 126 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x1C, BCMA_ANY_CLASS),
diff --git a/drivers/net/wireless/iwlwifi/dvm/lib.c b/drivers/net/wireless/iwlwifi/dvm/lib.c
index ab45819c1fbb..e18629a16fb0 100644
--- a/drivers/net/wireless/iwlwifi/dvm/lib.c
+++ b/drivers/net/wireless/iwlwifi/dvm/lib.c
@@ -1020,7 +1020,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
1020 u8 *pn = seq.ccmp.pn; 1020 u8 *pn = seq.ccmp.pn;
1021 1021
1022 ieee80211_get_key_rx_seq(key, i, &seq); 1022 ieee80211_get_key_rx_seq(key, i, &seq);
1023 aes_sc->pn = cpu_to_le64( 1023 aes_sc[i].pn = cpu_to_le64(
1024 (u64)pn[5] | 1024 (u64)pn[5] |
1025 ((u64)pn[4] << 8) | 1025 ((u64)pn[4] << 8) |
1026 ((u64)pn[3] << 16) | 1026 ((u64)pn[3] << 16) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-7000.c b/drivers/net/wireless/iwlwifi/iwl-7000.c
index 6951aba620eb..3fb327d5a911 100644
--- a/drivers/net/wireless/iwlwifi/iwl-7000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-7000.c
@@ -348,6 +348,6 @@ const struct iwl_cfg iwl7265d_n_cfg = {
348}; 348};
349 349
350MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); 350MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK));
351MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL3160_UCODE_API_OK)); 351MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL7260_UCODE_API_OK));
352MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); 352MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7260_UCODE_API_OK));
353MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); 353MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7260_UCODE_API_OK));
diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c
index 04264e417c1c..576187611e61 100644
--- a/drivers/net/wireless/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/iwlwifi/mvm/d3.c
@@ -274,18 +274,13 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
274 break; 274 break;
275 case WLAN_CIPHER_SUITE_CCMP: 275 case WLAN_CIPHER_SUITE_CCMP:
276 if (sta) { 276 if (sta) {
277 u8 *pn = seq.ccmp.pn; 277 u64 pn64;
278 278
279 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; 279 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
280 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; 280 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
281 281
282 ieee80211_get_key_tx_seq(key, &seq); 282 pn64 = atomic64_read(&key->tx_pn);
283 aes_tx_sc->pn = cpu_to_le64((u64)pn[5] | 283 aes_tx_sc->pn = cpu_to_le64(pn64);
284 ((u64)pn[4] << 8) |
285 ((u64)pn[3] << 16) |
286 ((u64)pn[2] << 24) |
287 ((u64)pn[1] << 32) |
288 ((u64)pn[0] << 40));
289 } else { 284 } else {
290 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; 285 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
291 } 286 }
@@ -298,12 +293,12 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
298 u8 *pn = seq.ccmp.pn; 293 u8 *pn = seq.ccmp.pn;
299 294
300 ieee80211_get_key_rx_seq(key, i, &seq); 295 ieee80211_get_key_rx_seq(key, i, &seq);
301 aes_sc->pn = cpu_to_le64((u64)pn[5] | 296 aes_sc[i].pn = cpu_to_le64((u64)pn[5] |
302 ((u64)pn[4] << 8) | 297 ((u64)pn[4] << 8) |
303 ((u64)pn[3] << 16) | 298 ((u64)pn[3] << 16) |
304 ((u64)pn[2] << 24) | 299 ((u64)pn[2] << 24) |
305 ((u64)pn[1] << 32) | 300 ((u64)pn[1] << 32) |
306 ((u64)pn[0] << 40)); 301 ((u64)pn[0] << 40));
307 } 302 }
308 data->use_rsc_tsc = true; 303 data->use_rsc_tsc = true;
309 break; 304 break;
@@ -1453,15 +1448,15 @@ static void iwl_mvm_d3_update_gtks(struct ieee80211_hw *hw,
1453 1448
1454 switch (key->cipher) { 1449 switch (key->cipher) {
1455 case WLAN_CIPHER_SUITE_CCMP: 1450 case WLAN_CIPHER_SUITE_CCMP:
1456 iwl_mvm_aes_sc_to_seq(&sc->aes.tsc, &seq);
1457 iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key); 1451 iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key);
1452 atomic64_set(&key->tx_pn, le64_to_cpu(sc->aes.tsc.pn));
1458 break; 1453 break;
1459 case WLAN_CIPHER_SUITE_TKIP: 1454 case WLAN_CIPHER_SUITE_TKIP:
1460 iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq); 1455 iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq);
1461 iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key); 1456 iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key);
1457 ieee80211_set_key_tx_seq(key, &seq);
1462 break; 1458 break;
1463 } 1459 }
1464 ieee80211_set_key_tx_seq(key, &seq);
1465 1460
1466 /* that's it for this key */ 1461 /* that's it for this key */
1467 return; 1462 return;
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c
index 4a0ce83315bd..5c7f7cc9ffcc 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c
@@ -703,7 +703,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
703 * abort after reading the nvm in case RF Kill is on, we will complete 703 * abort after reading the nvm in case RF Kill is on, we will complete
704 * the init seq later when RF kill will switch to off 704 * the init seq later when RF kill will switch to off
705 */ 705 */
706 if (iwl_mvm_is_radio_killed(mvm)) { 706 if (iwl_mvm_is_radio_hw_killed(mvm)) {
707 IWL_DEBUG_RF_KILL(mvm, 707 IWL_DEBUG_RF_KILL(mvm,
708 "jump over all phy activities due to RF kill\n"); 708 "jump over all phy activities due to RF kill\n");
709 iwl_remove_notification(&mvm->notif_wait, &calib_wait); 709 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
@@ -736,7 +736,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
736 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, 736 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
737 MVM_UCODE_CALIB_TIMEOUT); 737 MVM_UCODE_CALIB_TIMEOUT);
738 738
739 if (ret && iwl_mvm_is_radio_killed(mvm)) { 739 if (ret && iwl_mvm_is_radio_hw_killed(mvm)) {
740 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); 740 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
741 ret = 1; 741 ret = 1;
742 } 742 }
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index aa8c2b7f23c7..7c2944a72470 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -2388,6 +2388,7 @@ static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw,
2388 iwl_mvm_remove_time_event(mvm, mvmvif, 2388 iwl_mvm_remove_time_event(mvm, mvmvif,
2389 &mvmvif->time_event_data); 2389 &mvmvif->time_event_data);
2390 RCU_INIT_POINTER(mvm->csa_vif, NULL); 2390 RCU_INIT_POINTER(mvm->csa_vif, NULL);
2391 mvmvif->csa_countdown = false;
2391 } 2392 }
2392 2393
2393 if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { 2394 if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) {
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index b95a07ec9e36..c754051a4cea 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -860,6 +860,11 @@ static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
860 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); 860 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
861} 861}
862 862
863static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm)
864{
865 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
866}
867
863/* Must be called with rcu_read_lock() held and it can only be 868/* Must be called with rcu_read_lock() held and it can only be
864 * released when mvmsta is not needed anymore. 869 * released when mvmsta is not needed anymore.
865 */ 870 */
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index a37de3f410a0..f0cb092f980e 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -590,6 +590,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
590 ieee80211_unregister_hw(mvm->hw); 590 ieee80211_unregister_hw(mvm->hw);
591 iwl_mvm_leds_exit(mvm); 591 iwl_mvm_leds_exit(mvm);
592 out_free: 592 out_free:
593 flush_delayed_work(&mvm->fw_dump_wk);
593 iwl_phy_db_free(mvm->phy_db); 594 iwl_phy_db_free(mvm->phy_db);
594 kfree(mvm->scan_cmd); 595 kfree(mvm->scan_cmd);
595 if (!cfg->no_power_up_nic_in_init || !mvm->nvm_file_name) 596 if (!cfg->no_power_up_nic_in_init || !mvm->nvm_file_name)
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index b0825c402c73..644b58bc5226 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -414,6 +414,11 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
414 {IWL_PCI_DEVICE(0x095A, 0x5590, iwl7265_2ac_cfg)}, 414 {IWL_PCI_DEVICE(0x095A, 0x5590, iwl7265_2ac_cfg)},
415 {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)}, 415 {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)},
416 {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)}, 416 {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)},
417 {IWL_PCI_DEVICE(0x095A, 0x5F10, iwl7265_2ac_cfg)},
418 {IWL_PCI_DEVICE(0x095B, 0x5212, iwl7265_2ac_cfg)},
419 {IWL_PCI_DEVICE(0x095B, 0x520A, iwl7265_2ac_cfg)},
420 {IWL_PCI_DEVICE(0x095A, 0x9000, iwl7265_2ac_cfg)},
421 {IWL_PCI_DEVICE(0x095A, 0x9400, iwl7265_2ac_cfg)},
417 422
418/* 8000 Series */ 423/* 8000 Series */
419 {IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)}, 424 {IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)},
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 5932306084fd..bf9afbf46c1b 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1114,6 +1114,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1114 { USB_DEVICE(0x0db0, 0x871c) }, 1114 { USB_DEVICE(0x0db0, 0x871c) },
1115 { USB_DEVICE(0x0db0, 0x899a) }, 1115 { USB_DEVICE(0x0db0, 0x899a) },
1116 /* Ovislink */ 1116 /* Ovislink */
1117 { USB_DEVICE(0x1b75, 0x3070) },
1117 { USB_DEVICE(0x1b75, 0x3071) }, 1118 { USB_DEVICE(0x1b75, 0x3071) },
1118 { USB_DEVICE(0x1b75, 0x3072) }, 1119 { USB_DEVICE(0x1b75, 0x3072) },
1119 { USB_DEVICE(0x1b75, 0xa200) }, 1120 { USB_DEVICE(0x1b75, 0xa200) },
diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h
index d4567d12e07e..5da6703942d9 100644
--- a/drivers/net/wireless/rtlwifi/pci.h
+++ b/drivers/net/wireless/rtlwifi/pci.h
@@ -247,6 +247,8 @@ struct rtl_pci {
247 /* MSI support */ 247 /* MSI support */
248 bool msi_support; 248 bool msi_support;
249 bool using_msi; 249 bool using_msi;
250 /* interrupt clear before set */
251 bool int_clear;
250}; 252};
251 253
252struct mp_adapter { 254struct mp_adapter {
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
index b7f18e2155eb..6e9418ed90c2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
@@ -2253,11 +2253,28 @@ void rtl8821ae_set_qos(struct ieee80211_hw *hw, int aci)
2253 } 2253 }
2254} 2254}
2255 2255
2256static void rtl8821ae_clear_interrupt(struct ieee80211_hw *hw)
2257{
2258 struct rtl_priv *rtlpriv = rtl_priv(hw);
2259 u32 tmp = rtl_read_dword(rtlpriv, REG_HISR);
2260
2261 rtl_write_dword(rtlpriv, REG_HISR, tmp);
2262
2263 tmp = rtl_read_dword(rtlpriv, REG_HISRE);
2264 rtl_write_dword(rtlpriv, REG_HISRE, tmp);
2265
2266 tmp = rtl_read_dword(rtlpriv, REG_HSISR);
2267 rtl_write_dword(rtlpriv, REG_HSISR, tmp);
2268}
2269
2256void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw) 2270void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw)
2257{ 2271{
2258 struct rtl_priv *rtlpriv = rtl_priv(hw); 2272 struct rtl_priv *rtlpriv = rtl_priv(hw);
2259 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 2273 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2260 2274
2275 if (!rtlpci->int_clear)
2276 rtl8821ae_clear_interrupt(hw);/*clear it here first*/
2277
2261 rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF); 2278 rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF);
2262 rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); 2279 rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF);
2263 rtlpci->irq_enabled = true; 2280 rtlpci->irq_enabled = true;
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
index a4988121e1ab..8ee141a55bc5 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
@@ -96,6 +96,7 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
96 96
97 rtl8821ae_bt_reg_init(hw); 97 rtl8821ae_bt_reg_init(hw);
98 rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; 98 rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support;
99 rtlpci->int_clear = rtlpriv->cfg->mod_params->int_clear;
99 rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); 100 rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer();
100 101
101 rtlpriv->dm.dm_initialgain_enable = 1; 102 rtlpriv->dm.dm_initialgain_enable = 1;
@@ -167,6 +168,7 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
167 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; 168 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
168 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; 169 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
169 rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; 170 rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support;
171 rtlpci->msi_support = rtlpriv->cfg->mod_params->int_clear;
170 if (rtlpriv->cfg->mod_params->disable_watchdog) 172 if (rtlpriv->cfg->mod_params->disable_watchdog)
171 pr_info("watchdog disabled\n"); 173 pr_info("watchdog disabled\n");
172 rtlpriv->psc.reg_fwctrl_lps = 3; 174 rtlpriv->psc.reg_fwctrl_lps = 3;
@@ -308,6 +310,7 @@ static struct rtl_mod_params rtl8821ae_mod_params = {
308 .swctrl_lps = false, 310 .swctrl_lps = false,
309 .fwctrl_lps = true, 311 .fwctrl_lps = true,
310 .msi_support = true, 312 .msi_support = true,
313 .int_clear = true,
311 .debug = DBG_EMERG, 314 .debug = DBG_EMERG,
312 .disable_watchdog = 0, 315 .disable_watchdog = 0,
313}; 316};
@@ -437,6 +440,7 @@ module_param_named(fwlps, rtl8821ae_mod_params.fwctrl_lps, bool, 0444);
437module_param_named(msi, rtl8821ae_mod_params.msi_support, bool, 0444); 440module_param_named(msi, rtl8821ae_mod_params.msi_support, bool, 0444);
438module_param_named(disable_watchdog, rtl8821ae_mod_params.disable_watchdog, 441module_param_named(disable_watchdog, rtl8821ae_mod_params.disable_watchdog,
439 bool, 0444); 442 bool, 0444);
443module_param_named(int_clear, rtl8821ae_mod_params.int_clear, bool, 0444);
440MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n"); 444MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
441MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n"); 445MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
442MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n"); 446MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
@@ -444,6 +448,7 @@ MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
444MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 1)\n"); 448MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 1)\n");
445MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)"); 449MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)");
446MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n"); 450MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n");
451MODULE_PARM_DESC(int_clear, "Set to 1 to disable interrupt clear before set (default 0)\n");
447 452
448static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); 453static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
449 454
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index b90ca618b123..4544752a2ba8 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -2249,6 +2249,9 @@ struct rtl_mod_params {
2249 2249
2250 /* default 0: 1 means disable */ 2250 /* default 0: 1 means disable */
2251 bool disable_watchdog; 2251 bool disable_watchdog;
2252
2253 /* default 0: 1 means do not disable interrupts */
2254 bool int_clear;
2252}; 2255};
2253 2256
2254struct rtl_hal_usbint_cfg { 2257struct rtl_hal_usbint_cfg {
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 929a6e7e5ecf..56ebd8267386 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -788,6 +788,12 @@ static void connect(struct backend_info *be)
788 /* Use the number of queues requested by the frontend */ 788 /* Use the number of queues requested by the frontend */
789 be->vif->queues = vzalloc(requested_num_queues * 789 be->vif->queues = vzalloc(requested_num_queues *
790 sizeof(struct xenvif_queue)); 790 sizeof(struct xenvif_queue));
791 if (!be->vif->queues) {
792 xenbus_dev_fatal(dev, -ENOMEM,
793 "allocating queues");
794 return;
795 }
796
791 be->vif->num_queues = requested_num_queues; 797 be->vif->num_queues = requested_num_queues;
792 be->vif->stalled_queues = requested_num_queues; 798 be->vif->stalled_queues = requested_num_queues;
793 799
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f821a97d7827..6febc053a37f 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1706,19 +1706,19 @@ static void xennet_destroy_queues(struct netfront_info *info)
1706} 1706}
1707 1707
1708static int xennet_create_queues(struct netfront_info *info, 1708static int xennet_create_queues(struct netfront_info *info,
1709 unsigned int num_queues) 1709 unsigned int *num_queues)
1710{ 1710{
1711 unsigned int i; 1711 unsigned int i;
1712 int ret; 1712 int ret;
1713 1713
1714 info->queues = kcalloc(num_queues, sizeof(struct netfront_queue), 1714 info->queues = kcalloc(*num_queues, sizeof(struct netfront_queue),
1715 GFP_KERNEL); 1715 GFP_KERNEL);
1716 if (!info->queues) 1716 if (!info->queues)
1717 return -ENOMEM; 1717 return -ENOMEM;
1718 1718
1719 rtnl_lock(); 1719 rtnl_lock();
1720 1720
1721 for (i = 0; i < num_queues; i++) { 1721 for (i = 0; i < *num_queues; i++) {
1722 struct netfront_queue *queue = &info->queues[i]; 1722 struct netfront_queue *queue = &info->queues[i];
1723 1723
1724 queue->id = i; 1724 queue->id = i;
@@ -1728,7 +1728,7 @@ static int xennet_create_queues(struct netfront_info *info,
1728 if (ret < 0) { 1728 if (ret < 0) {
1729 dev_warn(&info->netdev->dev, 1729 dev_warn(&info->netdev->dev,
1730 "only created %d queues\n", i); 1730 "only created %d queues\n", i);
1731 num_queues = i; 1731 *num_queues = i;
1732 break; 1732 break;
1733 } 1733 }
1734 1734
@@ -1738,11 +1738,11 @@ static int xennet_create_queues(struct netfront_info *info,
1738 napi_enable(&queue->napi); 1738 napi_enable(&queue->napi);
1739 } 1739 }
1740 1740
1741 netif_set_real_num_tx_queues(info->netdev, num_queues); 1741 netif_set_real_num_tx_queues(info->netdev, *num_queues);
1742 1742
1743 rtnl_unlock(); 1743 rtnl_unlock();
1744 1744
1745 if (num_queues == 0) { 1745 if (*num_queues == 0) {
1746 dev_err(&info->netdev->dev, "no queues\n"); 1746 dev_err(&info->netdev->dev, "no queues\n");
1747 return -EINVAL; 1747 return -EINVAL;
1748 } 1748 }
@@ -1788,7 +1788,7 @@ static int talk_to_netback(struct xenbus_device *dev,
1788 if (info->queues) 1788 if (info->queues)
1789 xennet_destroy_queues(info); 1789 xennet_destroy_queues(info);
1790 1790
1791 err = xennet_create_queues(info, num_queues); 1791 err = xennet_create_queues(info, &num_queues);
1792 if (err < 0) 1792 if (err < 0)
1793 goto destroy_ring; 1793 goto destroy_ring;
1794 1794