aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_main.c11
-rw-r--r--drivers/net/can/slcan.c37
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c1
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c43
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c2
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c16
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.h2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c8
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c16
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c1
-rw-r--r--drivers/net/ethernet/dec/tulip/timer.c2
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h2
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c6
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c8
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c4
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c7
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_defines.h18
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_hw.h3
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_i210.c66
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_i210.h12
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_regs.h1
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c16
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c4
-rw-r--r--drivers/net/ethernet/marvell/skge.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cq.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_cq.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c17
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c34
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c69
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h4
-rw-r--r--drivers/net/ethernet/realtek/r8169.c25
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c5
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/enh_desc.c2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c7
-rw-r--r--drivers/net/ethernet/tile/tilegx.c1
-rw-r--r--drivers/net/fddi/defxx.c17
-rw-r--r--drivers/net/hyperv/netvsc.c2
-rw-r--r--drivers/net/ieee802154/at86rf230.c5
-rw-r--r--drivers/net/phy/at803x.c195
-rw-r--r--drivers/net/phy/dp83640.c6
-rw-r--r--drivers/net/phy/mdio_bus.c44
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/ppp/ppp_generic.c8
-rw-r--r--drivers/net/ppp/pppoe.c2
-rw-r--r--drivers/net/slip/slip.c36
-rw-r--r--drivers/net/slip/slip.h1
-rw-r--r--drivers/net/usb/hso.c50
-rw-r--r--drivers/net/usb/huawei_cdc_ncm.c7
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/net/usb/r8152.c7
-rw-r--r--drivers/net/usb/smsc95xx.c14
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c7
-rw-r--r--drivers/net/vmxnet3/vmxnet3_ethtool.c12
-rw-r--r--drivers/net/vmxnet3/vmxnet3_int.h5
-rw-r--r--drivers/net/wan/farsync.c112
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c6
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_rx.c18
-rw-r--r--drivers/net/wireless/b43/Kconfig2
-rw-r--r--drivers/net/wireless/b43/main.c1
-rw-r--r--drivers/net/wireless/b43/xmit.c10
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/usb.c5
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/rxon.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c19
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c65
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c3
-rw-r--r--drivers/net/wireless/mwifiex/11n_aggr.c1
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c1
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c1
-rw-r--r--drivers/net/wireless/mwifiex/main.c1
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c4
-rw-r--r--drivers/net/wireless/mwifiex/sta_tx.c1
-rw-r--r--drivers/net/wireless/mwifiex/tdls.c2
-rw-r--r--drivers/net/wireless/mwifiex/txrx.c1
-rw-r--r--drivers/net/wireless/mwifiex/uap_txrx.c1
-rw-r--r--drivers/net/wireless/mwifiex/util.h43
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c55
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c24
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.h1
-rw-r--r--drivers/net/xen-netback/common.h1
-rw-r--r--drivers/net/xen-netback/interface.c49
-rw-r--r--drivers/net/xen-netback/xenbus.c28
-rw-r--r--drivers/net/xen-netfront.c134
92 files changed, 954 insertions, 571 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 04f35f960cb8..701f86cd5993 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1025,10 +1025,14 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
1025 NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \ 1025 NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \
1026 NETIF_F_HIGHDMA | NETIF_F_LRO) 1026 NETIF_F_HIGHDMA | NETIF_F_LRO)
1027 1027
1028#define BOND_ENC_FEATURES (NETIF_F_ALL_CSUM | NETIF_F_SG | NETIF_F_RXCSUM |\
1029 NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL)
1030
1028static void bond_compute_features(struct bonding *bond) 1031static void bond_compute_features(struct bonding *bond)
1029{ 1032{
1030 unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE; 1033 unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE;
1031 netdev_features_t vlan_features = BOND_VLAN_FEATURES; 1034 netdev_features_t vlan_features = BOND_VLAN_FEATURES;
1035 netdev_features_t enc_features = BOND_ENC_FEATURES;
1032 struct net_device *bond_dev = bond->dev; 1036 struct net_device *bond_dev = bond->dev;
1033 struct list_head *iter; 1037 struct list_head *iter;
1034 struct slave *slave; 1038 struct slave *slave;
@@ -1044,6 +1048,9 @@ static void bond_compute_features(struct bonding *bond)
1044 vlan_features = netdev_increment_features(vlan_features, 1048 vlan_features = netdev_increment_features(vlan_features,
1045 slave->dev->vlan_features, BOND_VLAN_FEATURES); 1049 slave->dev->vlan_features, BOND_VLAN_FEATURES);
1046 1050
1051 enc_features = netdev_increment_features(enc_features,
1052 slave->dev->hw_enc_features,
1053 BOND_ENC_FEATURES);
1047 dst_release_flag &= slave->dev->priv_flags; 1054 dst_release_flag &= slave->dev->priv_flags;
1048 if (slave->dev->hard_header_len > max_hard_header_len) 1055 if (slave->dev->hard_header_len > max_hard_header_len)
1049 max_hard_header_len = slave->dev->hard_header_len; 1056 max_hard_header_len = slave->dev->hard_header_len;
@@ -1054,6 +1061,7 @@ static void bond_compute_features(struct bonding *bond)
1054 1061
1055done: 1062done:
1056 bond_dev->vlan_features = vlan_features; 1063 bond_dev->vlan_features = vlan_features;
1064 bond_dev->hw_enc_features = enc_features;
1057 bond_dev->hard_header_len = max_hard_header_len; 1065 bond_dev->hard_header_len = max_hard_header_len;
1058 bond_dev->gso_max_segs = gso_max_segs; 1066 bond_dev->gso_max_segs = gso_max_segs;
1059 netif_set_gso_max_size(bond_dev, gso_max_size); 1067 netif_set_gso_max_size(bond_dev, gso_max_size);
@@ -3975,6 +3983,7 @@ void bond_setup(struct net_device *bond_dev)
3975 NETIF_F_HW_VLAN_CTAG_FILTER; 3983 NETIF_F_HW_VLAN_CTAG_FILTER;
3976 3984
3977 bond_dev->hw_features &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_HW_CSUM); 3985 bond_dev->hw_features &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_HW_CSUM);
3986 bond_dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
3978 bond_dev->features |= bond_dev->hw_features; 3987 bond_dev->features |= bond_dev->hw_features;
3979} 3988}
3980 3989
@@ -4059,7 +4068,7 @@ static int bond_check_params(struct bond_params *params)
4059 } 4068 }
4060 4069
4061 if (ad_select) { 4070 if (ad_select) {
4062 bond_opt_initstr(&newval, lacp_rate); 4071 bond_opt_initstr(&newval, ad_select);
4063 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_AD_SELECT), 4072 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_AD_SELECT),
4064 &newval); 4073 &newval);
4065 if (!valptr) { 4074 if (!valptr) {
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index dcf9196f6316..ea4d4f1a6411 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -52,6 +52,7 @@
52#include <linux/delay.h> 52#include <linux/delay.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <linux/kernel.h> 54#include <linux/kernel.h>
55#include <linux/workqueue.h>
55#include <linux/can.h> 56#include <linux/can.h>
56#include <linux/can/skb.h> 57#include <linux/can/skb.h>
57 58
@@ -85,6 +86,7 @@ struct slcan {
85 struct tty_struct *tty; /* ptr to TTY structure */ 86 struct tty_struct *tty; /* ptr to TTY structure */
86 struct net_device *dev; /* easy for intr handling */ 87 struct net_device *dev; /* easy for intr handling */
87 spinlock_t lock; 88 spinlock_t lock;
89 struct work_struct tx_work; /* Flushes transmit buffer */
88 90
89 /* These are pointers to the malloc()ed frame buffers. */ 91 /* These are pointers to the malloc()ed frame buffers. */
90 unsigned char rbuff[SLC_MTU]; /* receiver buffer */ 92 unsigned char rbuff[SLC_MTU]; /* receiver buffer */
@@ -309,36 +311,46 @@ static void slc_encaps(struct slcan *sl, struct can_frame *cf)
309 sl->dev->stats.tx_bytes += cf->can_dlc; 311 sl->dev->stats.tx_bytes += cf->can_dlc;
310} 312}
311 313
312/* 314/* Write out any remaining transmit buffer. Scheduled when tty is writable */
313 * Called by the driver when there's room for more data. If we have 315static void slcan_transmit(struct work_struct *work)
314 * more packets to send, we send them here.
315 */
316static void slcan_write_wakeup(struct tty_struct *tty)
317{ 316{
317 struct slcan *sl = container_of(work, struct slcan, tx_work);
318 int actual; 318 int actual;
319 struct slcan *sl = (struct slcan *) tty->disc_data;
320 319
320 spin_lock_bh(&sl->lock);
321 /* First make sure we're connected. */ 321 /* First make sure we're connected. */
322 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) 322 if (!sl->tty || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) {
323 spin_unlock_bh(&sl->lock);
323 return; 324 return;
325 }
324 326
325 spin_lock_bh(&sl->lock);
326 if (sl->xleft <= 0) { 327 if (sl->xleft <= 0) {
327 /* Now serial buffer is almost free & we can start 328 /* Now serial buffer is almost free & we can start
328 * transmission of another packet */ 329 * transmission of another packet */
329 sl->dev->stats.tx_packets++; 330 sl->dev->stats.tx_packets++;
330 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 331 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
331 spin_unlock_bh(&sl->lock); 332 spin_unlock_bh(&sl->lock);
332 netif_wake_queue(sl->dev); 333 netif_wake_queue(sl->dev);
333 return; 334 return;
334 } 335 }
335 336
336 actual = tty->ops->write(tty, sl->xhead, sl->xleft); 337 actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft);
337 sl->xleft -= actual; 338 sl->xleft -= actual;
338 sl->xhead += actual; 339 sl->xhead += actual;
339 spin_unlock_bh(&sl->lock); 340 spin_unlock_bh(&sl->lock);
340} 341}
341 342
343/*
344 * Called by the driver when there's room for more data.
345 * Schedule the transmit.
346 */
347static void slcan_write_wakeup(struct tty_struct *tty)
348{
349 struct slcan *sl = tty->disc_data;
350
351 schedule_work(&sl->tx_work);
352}
353
342/* Send a can_frame to a TTY queue. */ 354/* Send a can_frame to a TTY queue. */
343static netdev_tx_t slc_xmit(struct sk_buff *skb, struct net_device *dev) 355static netdev_tx_t slc_xmit(struct sk_buff *skb, struct net_device *dev)
344{ 356{
@@ -528,6 +540,7 @@ static struct slcan *slc_alloc(dev_t line)
528 sl->magic = SLCAN_MAGIC; 540 sl->magic = SLCAN_MAGIC;
529 sl->dev = dev; 541 sl->dev = dev;
530 spin_lock_init(&sl->lock); 542 spin_lock_init(&sl->lock);
543 INIT_WORK(&sl->tx_work, slcan_transmit);
531 slcan_devs[i] = dev; 544 slcan_devs[i] = dev;
532 545
533 return sl; 546 return sl;
@@ -626,8 +639,12 @@ static void slcan_close(struct tty_struct *tty)
626 if (!sl || sl->magic != SLCAN_MAGIC || sl->tty != tty) 639 if (!sl || sl->magic != SLCAN_MAGIC || sl->tty != tty)
627 return; 640 return;
628 641
642 spin_lock_bh(&sl->lock);
629 tty->disc_data = NULL; 643 tty->disc_data = NULL;
630 sl->tty = NULL; 644 sl->tty = NULL;
645 spin_unlock_bh(&sl->lock);
646
647 flush_work(&sl->tx_work);
631 648
632 /* Flush network side */ 649 /* Flush network side */
633 unregister_netdev(sl->dev); 650 unregister_netdev(sl->dev);
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 28460676b8ca..d81e7167a8b5 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -736,6 +736,7 @@ static int emac_open(struct net_device *dev)
736 736
737 ret = emac_mdio_probe(dev); 737 ret = emac_mdio_probe(dev);
738 if (ret < 0) { 738 if (ret < 0) {
739 free_irq(dev->irq, dev);
739 netdev_err(dev, "cannot probe MDIO bus\n"); 740 netdev_err(dev, "cannot probe MDIO bus\n");
740 return ret; 741 return ret;
741 } 742 }
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 141160ef249a..5776e503e4c5 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -654,13 +654,13 @@ static int bcm_sysport_tx_poll(struct napi_struct *napi, int budget)
654 654
655 work_done = bcm_sysport_tx_reclaim(ring->priv, ring); 655 work_done = bcm_sysport_tx_reclaim(ring->priv, ring);
656 656
657 if (work_done < budget) { 657 if (work_done == 0) {
658 napi_complete(napi); 658 napi_complete(napi);
659 /* re-enable TX interrupt */ 659 /* re-enable TX interrupt */
660 intrl2_1_mask_clear(ring->priv, BIT(ring->index)); 660 intrl2_1_mask_clear(ring->priv, BIT(ring->index));
661 } 661 }
662 662
663 return work_done; 663 return 0;
664} 664}
665 665
666static void bcm_sysport_tx_reclaim_all(struct bcm_sysport_priv *priv) 666static void bcm_sysport_tx_reclaim_all(struct bcm_sysport_priv *priv)
@@ -1254,28 +1254,17 @@ static inline void umac_enable_set(struct bcm_sysport_priv *priv,
1254 usleep_range(1000, 2000); 1254 usleep_range(1000, 2000);
1255} 1255}
1256 1256
1257static inline int umac_reset(struct bcm_sysport_priv *priv) 1257static inline void umac_reset(struct bcm_sysport_priv *priv)
1258{ 1258{
1259 unsigned int timeout = 0;
1260 u32 reg; 1259 u32 reg;
1261 int ret = 0;
1262
1263 umac_writel(priv, 0, UMAC_CMD);
1264 while (timeout++ < 1000) {
1265 reg = umac_readl(priv, UMAC_CMD);
1266 if (!(reg & CMD_SW_RESET))
1267 break;
1268
1269 udelay(1);
1270 }
1271
1272 if (timeout == 1000) {
1273 dev_err(&priv->pdev->dev,
1274 "timeout waiting for MAC to come out of reset\n");
1275 ret = -ETIMEDOUT;
1276 }
1277 1260
1278 return ret; 1261 reg = umac_readl(priv, UMAC_CMD);
1262 reg |= CMD_SW_RESET;
1263 umac_writel(priv, reg, UMAC_CMD);
1264 udelay(10);
1265 reg = umac_readl(priv, UMAC_CMD);
1266 reg &= ~CMD_SW_RESET;
1267 umac_writel(priv, reg, UMAC_CMD);
1279} 1268}
1280 1269
1281static void umac_set_hw_addr(struct bcm_sysport_priv *priv, 1270static void umac_set_hw_addr(struct bcm_sysport_priv *priv,
@@ -1303,11 +1292,7 @@ static int bcm_sysport_open(struct net_device *dev)
1303 int ret; 1292 int ret;
1304 1293
1305 /* Reset UniMAC */ 1294 /* Reset UniMAC */
1306 ret = umac_reset(priv); 1295 umac_reset(priv);
1307 if (ret) {
1308 netdev_err(dev, "UniMAC reset failed\n");
1309 return ret;
1310 }
1311 1296
1312 /* Flush TX and RX FIFOs at TOPCTRL level */ 1297 /* Flush TX and RX FIFOs at TOPCTRL level */
1313 topctrl_flush(priv); 1298 topctrl_flush(priv);
@@ -1589,12 +1574,6 @@ static int bcm_sysport_probe(struct platform_device *pdev)
1589 BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8); 1574 BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8);
1590 dev->needed_headroom += sizeof(struct bcm_tsb); 1575 dev->needed_headroom += sizeof(struct bcm_tsb);
1591 1576
1592 /* We are interfaced to a switch which handles the multicast
1593 * filtering for us, so we do not support programming any
1594 * multicast hash table in this Ethernet MAC.
1595 */
1596 dev->flags &= ~IFF_MULTICAST;
1597
1598 /* libphy will adjust the link state accordingly */ 1577 /* libphy will adjust the link state accordingly */
1599 netif_carrier_off(dev); 1578 netif_carrier_off(dev);
1600 1579
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 47c5814114e1..4b875da1c7ed 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -797,7 +797,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
797 797
798 return; 798 return;
799 } 799 }
800 bnx2x_frag_free(fp, new_data); 800 if (new_data)
801 bnx2x_frag_free(fp, new_data);
801drop: 802drop:
802 /* drop the packet and keep the buffer in the bin */ 803 /* drop the packet and keep the buffer in the bin */
803 DP(NETIF_MSG_RX_STATUS, 804 DP(NETIF_MSG_RX_STATUS,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 2887034523e0..6a8b1453a1b9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -12937,7 +12937,7 @@ static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev, int cnic_cnt)
12937 * without the default SB. 12937 * without the default SB.
12938 * For VFs there is no default SB, then we return (index+1). 12938 * For VFs there is no default SB, then we return (index+1).
12939 */ 12939 */
12940 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSI_FLAGS, &control); 12940 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &control);
12941 12941
12942 index = control & PCI_MSIX_FLAGS_QSIZE; 12942 index = control & PCI_MSIX_FLAGS_QSIZE;
12943 12943
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 5ba1cfbd60da..16281ad2da12 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1408,13 +1408,6 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv)
1408 if (cb->skb) 1408 if (cb->skb)
1409 continue; 1409 continue;
1410 1410
1411 /* set the DMA descriptor length once and for all
1412 * it will only change if we support dynamically sizing
1413 * priv->rx_buf_len, but we do not
1414 */
1415 dmadesc_set_length_status(priv, priv->rx_bd_assign_ptr,
1416 priv->rx_buf_len << DMA_BUFLENGTH_SHIFT);
1417
1418 ret = bcmgenet_rx_refill(priv, cb); 1411 ret = bcmgenet_rx_refill(priv, cb);
1419 if (ret) 1412 if (ret)
1420 break; 1413 break;
@@ -2535,14 +2528,17 @@ static int bcmgenet_probe(struct platform_device *pdev)
2535 netif_set_real_num_tx_queues(priv->dev, priv->hw_params->tx_queues + 1); 2528 netif_set_real_num_tx_queues(priv->dev, priv->hw_params->tx_queues + 1);
2536 netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); 2529 netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1);
2537 2530
2538 err = register_netdev(dev); 2531 /* libphy will determine the link state */
2539 if (err) 2532 netif_carrier_off(dev);
2540 goto err_clk_disable;
2541 2533
2542 /* Turn off the main clock, WOL clock is handled separately */ 2534 /* Turn off the main clock, WOL clock is handled separately */
2543 if (!IS_ERR(priv->clk)) 2535 if (!IS_ERR(priv->clk))
2544 clk_disable_unprepare(priv->clk); 2536 clk_disable_unprepare(priv->clk);
2545 2537
2538 err = register_netdev(dev);
2539 if (err)
2540 goto err;
2541
2546 return err; 2542 return err;
2547 2543
2548err_clk_disable: 2544err_clk_disable:
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index 0f117105fed1..e23c993b1362 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -331,9 +331,9 @@ struct bcmgenet_mib_counters {
331#define EXT_ENERGY_DET_MASK (1 << 12) 331#define EXT_ENERGY_DET_MASK (1 << 12)
332 332
333#define EXT_RGMII_OOB_CTRL 0x0C 333#define EXT_RGMII_OOB_CTRL 0x0C
334#define RGMII_MODE_EN (1 << 0)
335#define RGMII_LINK (1 << 4) 334#define RGMII_LINK (1 << 4)
336#define OOB_DISABLE (1 << 5) 335#define OOB_DISABLE (1 << 5)
336#define RGMII_MODE_EN (1 << 6)
337#define ID_MODE_DIS (1 << 16) 337#define ID_MODE_DIS (1 << 16)
338 338
339#define EXT_GPHY_CTRL 0x1C 339#define EXT_GPHY_CTRL 0x1C
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index df2792d8383d..8afa579e7c40 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -3224,7 +3224,7 @@ static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
3224 return 0; 3224 return 0;
3225} 3225}
3226 3226
3227#define NVRAM_CMD_TIMEOUT 100 3227#define NVRAM_CMD_TIMEOUT 5000
3228 3228
3229static int tg3_nvram_exec_cmd(struct tg3 *tp, u32 nvram_cmd) 3229static int tg3_nvram_exec_cmd(struct tg3 *tp, u32 nvram_cmd)
3230{ 3230{
@@ -3232,7 +3232,7 @@ static int tg3_nvram_exec_cmd(struct tg3 *tp, u32 nvram_cmd)
3232 3232
3233 tw32(NVRAM_CMD, nvram_cmd); 3233 tw32(NVRAM_CMD, nvram_cmd);
3234 for (i = 0; i < NVRAM_CMD_TIMEOUT; i++) { 3234 for (i = 0; i < NVRAM_CMD_TIMEOUT; i++) {
3235 udelay(10); 3235 usleep_range(10, 40);
3236 if (tr32(NVRAM_CMD) & NVRAM_CMD_DONE) { 3236 if (tr32(NVRAM_CMD) & NVRAM_CMD_DONE) {
3237 udelay(10); 3237 udelay(10);
3238 break; 3238 break;
@@ -7854,8 +7854,8 @@ static int tg3_tso_bug(struct tg3 *tp, struct sk_buff *skb)
7854 netif_wake_queue(tp->dev); 7854 netif_wake_queue(tp->dev);
7855 } 7855 }
7856 7856
7857 segs = skb_gso_segment(skb, tp->dev->features & ~NETIF_F_TSO); 7857 segs = skb_gso_segment(skb, tp->dev->features & ~(NETIF_F_TSO | NETIF_F_TSO6));
7858 if (IS_ERR(segs)) 7858 if (IS_ERR(segs) || !segs)
7859 goto tg3_tso_bug_end; 7859 goto tg3_tso_bug_end;
7860 7860
7861 do { 7861 do {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 2f8d6b910383..a83271cf17c3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4057,22 +4057,19 @@ int cxgb4_unregister_uld(enum cxgb4_uld type)
4057EXPORT_SYMBOL(cxgb4_unregister_uld); 4057EXPORT_SYMBOL(cxgb4_unregister_uld);
4058 4058
4059/* Check if netdev on which event is occured belongs to us or not. Return 4059/* Check if netdev on which event is occured belongs to us or not. Return
4060 * suceess (1) if it belongs otherwise failure (0). 4060 * success (true) if it belongs otherwise failure (false).
4061 * Called with rcu_read_lock() held.
4061 */ 4062 */
4062static int cxgb4_netdev(struct net_device *netdev) 4063static bool cxgb4_netdev(const struct net_device *netdev)
4063{ 4064{
4064 struct adapter *adap; 4065 struct adapter *adap;
4065 int i; 4066 int i;
4066 4067
4067 spin_lock(&adap_rcu_lock);
4068 list_for_each_entry_rcu(adap, &adap_rcu_list, rcu_node) 4068 list_for_each_entry_rcu(adap, &adap_rcu_list, rcu_node)
4069 for (i = 0; i < MAX_NPORTS; i++) 4069 for (i = 0; i < MAX_NPORTS; i++)
4070 if (adap->port[i] == netdev) { 4070 if (adap->port[i] == netdev)
4071 spin_unlock(&adap_rcu_lock); 4071 return true;
4072 return 1; 4072 return false;
4073 }
4074 spin_unlock(&adap_rcu_lock);
4075 return 0;
4076} 4073}
4077 4074
4078static int clip_add(struct net_device *event_dev, struct inet6_ifaddr *ifa, 4075static int clip_add(struct net_device *event_dev, struct inet6_ifaddr *ifa,
@@ -6396,6 +6393,7 @@ static void remove_one(struct pci_dev *pdev)
6396 adapter->flags &= ~DEV_ENABLED; 6393 adapter->flags &= ~DEV_ENABLED;
6397 } 6394 }
6398 pci_release_regions(pdev); 6395 pci_release_regions(pdev);
6396 synchronize_rcu();
6399 kfree(adapter); 6397 kfree(adapter);
6400 } else 6398 } else
6401 pci_release_regions(pdev); 6399 pci_release_regions(pdev);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index bba67681aeaa..931478e7bd28 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3962,6 +3962,7 @@ int t4_port_init(struct adapter *adap, int mbox, int pf, int vf)
3962 p->lport = j; 3962 p->lport = j;
3963 p->rss_size = rss_size; 3963 p->rss_size = rss_size;
3964 memcpy(adap->port[i]->dev_addr, addr, ETH_ALEN); 3964 memcpy(adap->port[i]->dev_addr, addr, ETH_ALEN);
3965 adap->port[i]->dev_port = j;
3965 3966
3966 ret = ntohl(c.u.info.lstatus_to_modtype); 3967 ret = ntohl(c.u.info.lstatus_to_modtype);
3967 p->mdio_addr = (ret & FW_PORT_CMD_MDIOCAP) ? 3968 p->mdio_addr = (ret & FW_PORT_CMD_MDIOCAP) ?
diff --git a/drivers/net/ethernet/dec/tulip/timer.c b/drivers/net/ethernet/dec/tulip/timer.c
index 768379b8aee9..523d9dde50a2 100644
--- a/drivers/net/ethernet/dec/tulip/timer.c
+++ b/drivers/net/ethernet/dec/tulip/timer.c
@@ -158,7 +158,7 @@ void comet_timer(unsigned long data)
158{ 158{
159 struct net_device *dev = (struct net_device *)data; 159 struct net_device *dev = (struct net_device *)data;
160 struct tulip_private *tp = netdev_priv(dev); 160 struct tulip_private *tp = netdev_priv(dev);
161 int next_tick = 60*HZ; 161 int next_tick = 2*HZ;
162 162
163 if (tulip_debug > 1) 163 if (tulip_debug > 1)
164 netdev_dbg(dev, "Comet link status %04x partner capability %04x\n", 164 netdev_dbg(dev, "Comet link status %04x partner capability %04x\n",
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 2e7c5553955e..c2f5d2d3b932 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -557,9 +557,7 @@ static inline u16 be_max_qs(struct be_adapter *adapter)
557#define be_pvid_tagging_enabled(adapter) (adapter->pvid) 557#define be_pvid_tagging_enabled(adapter) (adapter->pvid)
558 558
559/* Is BE in QNQ multi-channel mode */ 559/* Is BE in QNQ multi-channel mode */
560#define be_is_qnq_mode(adapter) (adapter->mc_type == FLEX10 || \ 560#define be_is_qnq_mode(adapter) (adapter->function_mode & QNQ_MODE)
561 adapter->mc_type == vNIC1 || \
562 adapter->mc_type == UFP)
563 561
564#define lancer_chip(adapter) (adapter->pdev->device == OC_DEVICE_ID3 || \ 562#define lancer_chip(adapter) (adapter->pdev->device == OC_DEVICE_ID3 || \
565 adapter->pdev->device == OC_DEVICE_ID4) 563 adapter->pdev->device == OC_DEVICE_ID4)
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 3e0a6b243806..59b3c056f329 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1091,7 +1091,7 @@ struct be_cmd_resp_modify_eq_delay {
1091 * based on the skew/IPL. 1091 * based on the skew/IPL.
1092 */ 1092 */
1093#define RDMA_ENABLED 0x4 1093#define RDMA_ENABLED 0x4
1094#define FLEX10_MODE 0x400 1094#define QNQ_MODE 0x400
1095#define VNIC_MODE 0x20000 1095#define VNIC_MODE 0x20000
1096#define UMC_ENABLED 0x1000000 1096#define UMC_ENABLED 0x1000000
1097struct be_cmd_req_query_fw_cfg { 1097struct be_cmd_req_query_fw_cfg {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 6822b3d76d85..1e187fb760f8 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2902,7 +2902,7 @@ static int be_open(struct net_device *netdev)
2902 for_all_evt_queues(adapter, eqo, i) { 2902 for_all_evt_queues(adapter, eqo, i) {
2903 napi_enable(&eqo->napi); 2903 napi_enable(&eqo->napi);
2904 be_enable_busy_poll(eqo); 2904 be_enable_busy_poll(eqo);
2905 be_eq_notify(adapter, eqo->q.id, true, false, 0); 2905 be_eq_notify(adapter, eqo->q.id, true, true, 0);
2906 } 2906 }
2907 adapter->flags |= BE_FLAGS_NAPI_ENABLED; 2907 adapter->flags |= BE_FLAGS_NAPI_ENABLED;
2908 2908
@@ -3254,9 +3254,9 @@ err:
3254 3254
3255static u8 be_convert_mc_type(u32 function_mode) 3255static u8 be_convert_mc_type(u32 function_mode)
3256{ 3256{
3257 if (function_mode & VNIC_MODE && function_mode & FLEX10_MODE) 3257 if (function_mode & VNIC_MODE && function_mode & QNQ_MODE)
3258 return vNIC1; 3258 return vNIC1;
3259 else if (function_mode & FLEX10_MODE) 3259 else if (function_mode & QNQ_MODE)
3260 return FLEX10; 3260 return FLEX10;
3261 else if (function_mode & VNIC_MODE) 3261 else if (function_mode & VNIC_MODE)
3262 return vNIC2; 3262 return vNIC2;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 38d9d276ab8b..77037fd377b8 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -320,6 +320,11 @@ static void *swap_buffer(void *bufaddr, int len)
320 return bufaddr; 320 return bufaddr;
321} 321}
322 322
323static inline bool is_ipv4_pkt(struct sk_buff *skb)
324{
325 return skb->protocol == htons(ETH_P_IP) && ip_hdr(skb)->version == 4;
326}
327
323static int 328static int
324fec_enet_clear_csum(struct sk_buff *skb, struct net_device *ndev) 329fec_enet_clear_csum(struct sk_buff *skb, struct net_device *ndev)
325{ 330{
@@ -330,7 +335,8 @@ fec_enet_clear_csum(struct sk_buff *skb, struct net_device *ndev)
330 if (unlikely(skb_cow_head(skb, 0))) 335 if (unlikely(skb_cow_head(skb, 0)))
331 return -1; 336 return -1;
332 337
333 ip_hdr(skb)->check = 0; 338 if (is_ipv4_pkt(skb))
339 ip_hdr(skb)->check = 0;
334 *(__sum16 *)(skb->head + skb->csum_start + skb->csum_offset) = 0; 340 *(__sum16 *)(skb->head + skb->csum_start + skb->csum_offset) = 0;
335 341
336 return 0; 342 return 0;
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index fab39e295441..36fc429298e3 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -2990,11 +2990,11 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2990 if (ug_info->rxExtendedFiltering) { 2990 if (ug_info->rxExtendedFiltering) {
2991 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 2991 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
2992 if (ug_info->largestexternallookupkeysize == 2992 if (ug_info->largestexternallookupkeysize ==
2993 QE_FLTR_TABLE_LOOKUP_KEY_SIZE_8_BYTES) 2993 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_8_BYTES)
2994 size += 2994 size +=
2995 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8; 2995 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8;
2996 if (ug_info->largestexternallookupkeysize == 2996 if (ug_info->largestexternallookupkeysize ==
2997 QE_FLTR_TABLE_LOOKUP_KEY_SIZE_16_BYTES) 2997 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_16_BYTES)
2998 size += 2998 size +=
2999 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16; 2999 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16;
3000 } 3000 }
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index a2db388cc31e..ee74f9536b31 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -1481,6 +1481,13 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)
1481 s32 ret_val; 1481 s32 ret_val;
1482 u16 i, rar_count = mac->rar_entry_count; 1482 u16 i, rar_count = mac->rar_entry_count;
1483 1483
1484 if ((hw->mac.type >= e1000_i210) &&
1485 !(igb_get_flash_presence_i210(hw))) {
1486 ret_val = igb_pll_workaround_i210(hw);
1487 if (ret_val)
1488 return ret_val;
1489 }
1490
1484 /* Initialize identification LED */ 1491 /* Initialize identification LED */
1485 ret_val = igb_id_led_init(hw); 1492 ret_val = igb_id_led_init(hw);
1486 if (ret_val) { 1493 if (ret_val) {
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
index 2a8bb35c2df2..217f8138851b 100644
--- a/drivers/net/ethernet/intel/igb/e1000_defines.h
+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h
@@ -46,14 +46,15 @@
46#define E1000_CTRL_EXT_SDP3_DIR 0x00000800 /* SDP3 Data direction */ 46#define E1000_CTRL_EXT_SDP3_DIR 0x00000800 /* SDP3 Data direction */
47 47
48/* Physical Func Reset Done Indication */ 48/* Physical Func Reset Done Indication */
49#define E1000_CTRL_EXT_PFRSTD 0x00004000 49#define E1000_CTRL_EXT_PFRSTD 0x00004000
50#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 50#define E1000_CTRL_EXT_SDLPE 0X00040000 /* SerDes Low Power Enable */
51#define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000 51#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
52#define E1000_CTRL_EXT_LINK_MODE_1000BASE_KX 0x00400000 52#define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000
53#define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000 53#define E1000_CTRL_EXT_LINK_MODE_1000BASE_KX 0x00400000
54#define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000 54#define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000
55#define E1000_CTRL_EXT_EIAME 0x01000000 55#define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000
56#define E1000_CTRL_EXT_IRCA 0x00000001 56#define E1000_CTRL_EXT_EIAME 0x01000000
57#define E1000_CTRL_EXT_IRCA 0x00000001
57/* Interrupt delay cancellation */ 58/* Interrupt delay cancellation */
58/* Driver loaded bit for FW */ 59/* Driver loaded bit for FW */
59#define E1000_CTRL_EXT_DRV_LOAD 0x10000000 60#define E1000_CTRL_EXT_DRV_LOAD 0x10000000
@@ -62,6 +63,7 @@
62/* packet buffer parity error detection enabled */ 63/* packet buffer parity error detection enabled */
63/* descriptor FIFO parity error detection enable */ 64/* descriptor FIFO parity error detection enable */
64#define E1000_CTRL_EXT_PBA_CLR 0x80000000 /* PBA Clear */ 65#define E1000_CTRL_EXT_PBA_CLR 0x80000000 /* PBA Clear */
66#define E1000_CTRL_EXT_PHYPDEN 0x00100000
65#define E1000_I2CCMD_REG_ADDR_SHIFT 16 67#define E1000_I2CCMD_REG_ADDR_SHIFT 16
66#define E1000_I2CCMD_PHY_ADDR_SHIFT 24 68#define E1000_I2CCMD_PHY_ADDR_SHIFT 24
67#define E1000_I2CCMD_OPCODE_READ 0x08000000 69#define E1000_I2CCMD_OPCODE_READ 0x08000000
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
index 89925e405849..ce55ea5d750c 100644
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
@@ -567,4 +567,7 @@ struct net_device *igb_get_hw_dev(struct e1000_hw *hw);
567/* These functions must be implemented by drivers */ 567/* These functions must be implemented by drivers */
568s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); 568s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
569s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); 569s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
570
571void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
572void igb_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
570#endif /* _E1000_HW_H_ */ 573#endif /* _E1000_HW_H_ */
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c
index 337161f440dd..65d931669f81 100644
--- a/drivers/net/ethernet/intel/igb/e1000_i210.c
+++ b/drivers/net/ethernet/intel/igb/e1000_i210.c
@@ -834,3 +834,69 @@ s32 igb_init_nvm_params_i210(struct e1000_hw *hw)
834 } 834 }
835 return ret_val; 835 return ret_val;
836} 836}
837
838/**
839 * igb_pll_workaround_i210
840 * @hw: pointer to the HW structure
841 *
842 * Works around an errata in the PLL circuit where it occasionally
843 * provides the wrong clock frequency after power up.
844 **/
845s32 igb_pll_workaround_i210(struct e1000_hw *hw)
846{
847 s32 ret_val;
848 u32 wuc, mdicnfg, ctrl, ctrl_ext, reg_val;
849 u16 nvm_word, phy_word, pci_word, tmp_nvm;
850 int i;
851
852 /* Get and set needed register values */
853 wuc = rd32(E1000_WUC);
854 mdicnfg = rd32(E1000_MDICNFG);
855 reg_val = mdicnfg & ~E1000_MDICNFG_EXT_MDIO;
856 wr32(E1000_MDICNFG, reg_val);
857
858 /* Get data from NVM, or set default */
859 ret_val = igb_read_invm_word_i210(hw, E1000_INVM_AUTOLOAD,
860 &nvm_word);
861 if (ret_val)
862 nvm_word = E1000_INVM_DEFAULT_AL;
863 tmp_nvm = nvm_word | E1000_INVM_PLL_WO_VAL;
864 for (i = 0; i < E1000_MAX_PLL_TRIES; i++) {
865 /* check current state directly from internal PHY */
866 igb_read_phy_reg_gs40g(hw, (E1000_PHY_PLL_FREQ_PAGE |
867 E1000_PHY_PLL_FREQ_REG), &phy_word);
868 if ((phy_word & E1000_PHY_PLL_UNCONF)
869 != E1000_PHY_PLL_UNCONF) {
870 ret_val = 0;
871 break;
872 } else {
873 ret_val = -E1000_ERR_PHY;
874 }
875 /* directly reset the internal PHY */
876 ctrl = rd32(E1000_CTRL);
877 wr32(E1000_CTRL, ctrl|E1000_CTRL_PHY_RST);
878
879 ctrl_ext = rd32(E1000_CTRL_EXT);
880 ctrl_ext |= (E1000_CTRL_EXT_PHYPDEN | E1000_CTRL_EXT_SDLPE);
881 wr32(E1000_CTRL_EXT, ctrl_ext);
882
883 wr32(E1000_WUC, 0);
884 reg_val = (E1000_INVM_AUTOLOAD << 4) | (tmp_nvm << 16);
885 wr32(E1000_EEARBC_I210, reg_val);
886
887 igb_read_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word);
888 pci_word |= E1000_PCI_PMCSR_D3;
889 igb_write_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word);
890 usleep_range(1000, 2000);
891 pci_word &= ~E1000_PCI_PMCSR_D3;
892 igb_write_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word);
893 reg_val = (E1000_INVM_AUTOLOAD << 4) | (nvm_word << 16);
894 wr32(E1000_EEARBC_I210, reg_val);
895
896 /* restore WUC register */
897 wr32(E1000_WUC, wuc);
898 }
899 /* restore MDICNFG setting */
900 wr32(E1000_MDICNFG, mdicnfg);
901 return ret_val;
902}
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.h b/drivers/net/ethernet/intel/igb/e1000_i210.h
index 9f34976687ba..3442b6357d01 100644
--- a/drivers/net/ethernet/intel/igb/e1000_i210.h
+++ b/drivers/net/ethernet/intel/igb/e1000_i210.h
@@ -33,6 +33,7 @@ s32 igb_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 *data);
33s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data); 33s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data);
34s32 igb_init_nvm_params_i210(struct e1000_hw *hw); 34s32 igb_init_nvm_params_i210(struct e1000_hw *hw);
35bool igb_get_flash_presence_i210(struct e1000_hw *hw); 35bool igb_get_flash_presence_i210(struct e1000_hw *hw);
36s32 igb_pll_workaround_i210(struct e1000_hw *hw);
36 37
37#define E1000_STM_OPCODE 0xDB00 38#define E1000_STM_OPCODE 0xDB00
38#define E1000_EEPROM_FLASH_SIZE_WORD 0x11 39#define E1000_EEPROM_FLASH_SIZE_WORD 0x11
@@ -78,4 +79,15 @@ enum E1000_INVM_STRUCTURE_TYPE {
78#define NVM_LED_1_CFG_DEFAULT_I211 0x0184 79#define NVM_LED_1_CFG_DEFAULT_I211 0x0184
79#define NVM_LED_0_2_CFG_DEFAULT_I211 0x200C 80#define NVM_LED_0_2_CFG_DEFAULT_I211 0x200C
80 81
82/* PLL Defines */
83#define E1000_PCI_PMCSR 0x44
84#define E1000_PCI_PMCSR_D3 0x03
85#define E1000_MAX_PLL_TRIES 5
86#define E1000_PHY_PLL_UNCONF 0xFF
87#define E1000_PHY_PLL_FREQ_PAGE 0xFC0000
88#define E1000_PHY_PLL_FREQ_REG 0x000E
89#define E1000_INVM_DEFAULT_AL 0x202F
90#define E1000_INVM_AUTOLOAD 0x0A
91#define E1000_INVM_PLL_WO_VAL 0x0010
92
81#endif 93#endif
diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h
index 1cc4b1a7e597..f5ba4e4eafb9 100644
--- a/drivers/net/ethernet/intel/igb/e1000_regs.h
+++ b/drivers/net/ethernet/intel/igb/e1000_regs.h
@@ -66,6 +66,7 @@
66#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */ 66#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */
67#define E1000_PBS 0x01008 /* Packet Buffer Size */ 67#define E1000_PBS 0x01008 /* Packet Buffer Size */
68#define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */ 68#define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */
69#define E1000_EEARBC_I210 0x12024 /* EEPROM Auto Read Bus Control */
69#define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */ 70#define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */
70#define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */ 71#define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */
71#define E1000_FRTIMER 0x01048 /* Free Running Timer - RW */ 72#define E1000_FRTIMER 0x01048 /* Free Running Timer - RW */
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index f145adbb55ac..a9537ba7a5a0 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -7215,6 +7215,20 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
7215 } 7215 }
7216} 7216}
7217 7217
7218void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
7219{
7220 struct igb_adapter *adapter = hw->back;
7221
7222 pci_read_config_word(adapter->pdev, reg, value);
7223}
7224
7225void igb_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
7226{
7227 struct igb_adapter *adapter = hw->back;
7228
7229 pci_write_config_word(adapter->pdev, reg, *value);
7230}
7231
7218s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) 7232s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
7219{ 7233{
7220 struct igb_adapter *adapter = hw->back; 7234 struct igb_adapter *adapter = hw->back;
@@ -7578,6 +7592,8 @@ static int igb_sriov_reinit(struct pci_dev *dev)
7578 7592
7579 if (netif_running(netdev)) 7593 if (netif_running(netdev))
7580 igb_close(netdev); 7594 igb_close(netdev);
7595 else
7596 igb_reset(adapter);
7581 7597
7582 igb_clear_interrupt_scheme(adapter); 7598 igb_clear_interrupt_scheme(adapter);
7583 7599
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 45beca17fa50..dadd9a5f6323 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1207,7 +1207,7 @@ static u32 mvneta_txq_desc_csum(int l3_offs, int l3_proto,
1207 command = l3_offs << MVNETA_TX_L3_OFF_SHIFT; 1207 command = l3_offs << MVNETA_TX_L3_OFF_SHIFT;
1208 command |= ip_hdr_len << MVNETA_TX_IP_HLEN_SHIFT; 1208 command |= ip_hdr_len << MVNETA_TX_IP_HLEN_SHIFT;
1209 1209
1210 if (l3_proto == swab16(ETH_P_IP)) 1210 if (l3_proto == htons(ETH_P_IP))
1211 command |= MVNETA_TXD_IP_CSUM; 1211 command |= MVNETA_TXD_IP_CSUM;
1212 else 1212 else
1213 command |= MVNETA_TX_L3_IP6; 1213 command |= MVNETA_TX_L3_IP6;
@@ -2529,7 +2529,7 @@ static void mvneta_adjust_link(struct net_device *ndev)
2529 2529
2530 if (phydev->speed == SPEED_1000) 2530 if (phydev->speed == SPEED_1000)
2531 val |= MVNETA_GMAC_CONFIG_GMII_SPEED; 2531 val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
2532 else 2532 else if (phydev->speed == SPEED_100)
2533 val |= MVNETA_GMAC_CONFIG_MII_SPEED; 2533 val |= MVNETA_GMAC_CONFIG_MII_SPEED;
2534 2534
2535 mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val); 2535 mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 7f81ae66cc89..e912b6887d40 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -4199,6 +4199,13 @@ static struct dmi_system_id skge_32bit_dma_boards[] = {
4199 DMI_MATCH(DMI_BOARD_NAME, "P5NSLI") 4199 DMI_MATCH(DMI_BOARD_NAME, "P5NSLI")
4200 }, 4200 },
4201 }, 4201 },
4202 {
4203 .ident = "FUJITSU SIEMENS A8NE-FM",
4204 .matches = {
4205 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
4206 DMI_MATCH(DMI_BOARD_NAME, "A8NE-FM")
4207 },
4208 },
4202 {} 4209 {}
4203}; 4210};
4204 4211
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c
index 80f725228f5b..56022d647837 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cq.c
@@ -294,8 +294,6 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent,
294 init_completion(&cq->free); 294 init_completion(&cq->free);
295 295
296 cq->irq = priv->eq_table.eq[cq->vector].irq; 296 cq->irq = priv->eq_table.eq[cq->vector].irq;
297 cq->irq_affinity_change = false;
298
299 return 0; 297 return 0;
300 298
301err_radix: 299err_radix:
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
index 4b2130760eed..14c00048bbec 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
@@ -128,6 +128,10 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
128 mlx4_warn(mdev, "Failed assigning an EQ to %s, falling back to legacy EQ's\n", 128 mlx4_warn(mdev, "Failed assigning an EQ to %s, falling back to legacy EQ's\n",
129 name); 129 name);
130 } 130 }
131
132 cq->irq_desc =
133 irq_to_desc(mlx4_eq_get_irq(mdev->dev,
134 cq->vector));
131 } 135 }
132 } else { 136 } else {
133 cq->vector = (cq->ring + 1 + priv->port) % 137 cq->vector = (cq->ring + 1 + priv->port) %
@@ -187,8 +191,6 @@ void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq)
187 mlx4_en_unmap_buffer(&cq->wqres.buf); 191 mlx4_en_unmap_buffer(&cq->wqres.buf);
188 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); 192 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size);
189 if (priv->mdev->dev->caps.comp_pool && cq->vector) { 193 if (priv->mdev->dev->caps.comp_pool && cq->vector) {
190 if (!cq->is_tx)
191 irq_set_affinity_hint(cq->mcq.irq, NULL);
192 mlx4_release_eq(priv->mdev->dev, cq->vector); 194 mlx4_release_eq(priv->mdev->dev, cq->vector);
193 } 195 }
194 cq->vector = 0; 196 cq->vector = 0;
@@ -204,6 +206,7 @@ void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq)
204 if (!cq->is_tx) { 206 if (!cq->is_tx) {
205 napi_hash_del(&cq->napi); 207 napi_hash_del(&cq->napi);
206 synchronize_rcu(); 208 synchronize_rcu();
209 irq_set_affinity_hint(cq->mcq.irq, NULL);
207 } 210 }
208 netif_napi_del(&cq->napi); 211 netif_napi_del(&cq->napi);
209 212
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index fa1a069e14e6..68d763d2d030 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -417,6 +417,8 @@ static int mlx4_en_get_coalesce(struct net_device *dev,
417 417
418 coal->tx_coalesce_usecs = priv->tx_usecs; 418 coal->tx_coalesce_usecs = priv->tx_usecs;
419 coal->tx_max_coalesced_frames = priv->tx_frames; 419 coal->tx_max_coalesced_frames = priv->tx_frames;
420 coal->tx_max_coalesced_frames_irq = priv->tx_work_limit;
421
420 coal->rx_coalesce_usecs = priv->rx_usecs; 422 coal->rx_coalesce_usecs = priv->rx_usecs;
421 coal->rx_max_coalesced_frames = priv->rx_frames; 423 coal->rx_max_coalesced_frames = priv->rx_frames;
422 424
@@ -426,6 +428,7 @@ static int mlx4_en_get_coalesce(struct net_device *dev,
426 coal->rx_coalesce_usecs_high = priv->rx_usecs_high; 428 coal->rx_coalesce_usecs_high = priv->rx_usecs_high;
427 coal->rate_sample_interval = priv->sample_interval; 429 coal->rate_sample_interval = priv->sample_interval;
428 coal->use_adaptive_rx_coalesce = priv->adaptive_rx_coal; 430 coal->use_adaptive_rx_coalesce = priv->adaptive_rx_coal;
431
429 return 0; 432 return 0;
430} 433}
431 434
@@ -434,6 +437,9 @@ static int mlx4_en_set_coalesce(struct net_device *dev,
434{ 437{
435 struct mlx4_en_priv *priv = netdev_priv(dev); 438 struct mlx4_en_priv *priv = netdev_priv(dev);
436 439
440 if (!coal->tx_max_coalesced_frames_irq)
441 return -EINVAL;
442
437 priv->rx_frames = (coal->rx_max_coalesced_frames == 443 priv->rx_frames = (coal->rx_max_coalesced_frames ==
438 MLX4_EN_AUTO_CONF) ? 444 MLX4_EN_AUTO_CONF) ?
439 MLX4_EN_RX_COAL_TARGET : 445 MLX4_EN_RX_COAL_TARGET :
@@ -457,6 +463,7 @@ static int mlx4_en_set_coalesce(struct net_device *dev,
457 priv->rx_usecs_high = coal->rx_coalesce_usecs_high; 463 priv->rx_usecs_high = coal->rx_coalesce_usecs_high;
458 priv->sample_interval = coal->rate_sample_interval; 464 priv->sample_interval = coal->rate_sample_interval;
459 priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; 465 priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce;
466 priv->tx_work_limit = coal->tx_max_coalesced_frames_irq;
460 467
461 return mlx4_en_moderation_update(priv); 468 return mlx4_en_moderation_update(priv);
462} 469}
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 7d4fb7bf2593..7345c43b019e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2336,7 +2336,7 @@ static void mlx4_en_add_vxlan_port(struct net_device *dev,
2336 struct mlx4_en_priv *priv = netdev_priv(dev); 2336 struct mlx4_en_priv *priv = netdev_priv(dev);
2337 __be16 current_port; 2337 __be16 current_port;
2338 2338
2339 if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS)) 2339 if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
2340 return; 2340 return;
2341 2341
2342 if (sa_family == AF_INET6) 2342 if (sa_family == AF_INET6)
@@ -2473,6 +2473,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2473 MLX4_WQE_CTRL_SOLICITED); 2473 MLX4_WQE_CTRL_SOLICITED);
2474 priv->num_tx_rings_p_up = mdev->profile.num_tx_rings_p_up; 2474 priv->num_tx_rings_p_up = mdev->profile.num_tx_rings_p_up;
2475 priv->tx_ring_num = prof->tx_ring_num; 2475 priv->tx_ring_num = prof->tx_ring_num;
2476 priv->tx_work_limit = MLX4_EN_DEFAULT_TX_WORK;
2476 2477
2477 priv->tx_ring = kzalloc(sizeof(struct mlx4_en_tx_ring *) * MAX_TX_RINGS, 2478 priv->tx_ring = kzalloc(sizeof(struct mlx4_en_tx_ring *) * MAX_TX_RINGS,
2478 GFP_KERNEL); 2479 GFP_KERNEL);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index d2d415732d99..5535862f27cc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -40,6 +40,7 @@
40#include <linux/if_ether.h> 40#include <linux/if_ether.h>
41#include <linux/if_vlan.h> 41#include <linux/if_vlan.h>
42#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
43#include <linux/irq.h>
43 44
44#include "mlx4_en.h" 45#include "mlx4_en.h"
45 46
@@ -782,6 +783,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
782 PKT_HASH_TYPE_L3); 783 PKT_HASH_TYPE_L3);
783 784
784 skb_record_rx_queue(gro_skb, cq->ring); 785 skb_record_rx_queue(gro_skb, cq->ring);
786 skb_mark_napi_id(gro_skb, &cq->napi);
785 787
786 if (ring->hwtstamp_rx_filter == HWTSTAMP_FILTER_ALL) { 788 if (ring->hwtstamp_rx_filter == HWTSTAMP_FILTER_ALL) {
787 timestamp = mlx4_en_get_cqe_ts(cqe); 789 timestamp = mlx4_en_get_cqe_ts(cqe);
@@ -896,16 +898,25 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
896 898
897 /* If we used up all the quota - we're probably not done yet... */ 899 /* If we used up all the quota - we're probably not done yet... */
898 if (done == budget) { 900 if (done == budget) {
901 int cpu_curr;
902 const struct cpumask *aff;
903
899 INC_PERF_COUNTER(priv->pstats.napi_quota); 904 INC_PERF_COUNTER(priv->pstats.napi_quota);
900 if (unlikely(cq->mcq.irq_affinity_change)) { 905
901 cq->mcq.irq_affinity_change = false; 906 cpu_curr = smp_processor_id();
907 aff = irq_desc_get_irq_data(cq->irq_desc)->affinity;
908
909 if (unlikely(!cpumask_test_cpu(cpu_curr, aff))) {
910 /* Current cpu is not according to smp_irq_affinity -
911 * probably affinity changed. need to stop this NAPI
912 * poll, and restart it on the right CPU
913 */
902 napi_complete(napi); 914 napi_complete(napi);
903 mlx4_en_arm_cq(priv, cq); 915 mlx4_en_arm_cq(priv, cq);
904 return 0; 916 return 0;
905 } 917 }
906 } else { 918 } else {
907 /* Done for now */ 919 /* Done for now */
908 cq->mcq.irq_affinity_change = false;
909 napi_complete(napi); 920 napi_complete(napi);
910 mlx4_en_arm_cq(priv, cq); 921 mlx4_en_arm_cq(priv, cq);
911 } 922 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 8be7483f8236..5045bab59633 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -351,9 +351,8 @@ int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring)
351 return cnt; 351 return cnt;
352} 352}
353 353
354static int mlx4_en_process_tx_cq(struct net_device *dev, 354static bool mlx4_en_process_tx_cq(struct net_device *dev,
355 struct mlx4_en_cq *cq, 355 struct mlx4_en_cq *cq)
356 int budget)
357{ 356{
358 struct mlx4_en_priv *priv = netdev_priv(dev); 357 struct mlx4_en_priv *priv = netdev_priv(dev);
359 struct mlx4_cq *mcq = &cq->mcq; 358 struct mlx4_cq *mcq = &cq->mcq;
@@ -372,9 +371,10 @@ static int mlx4_en_process_tx_cq(struct net_device *dev,
372 int factor = priv->cqe_factor; 371 int factor = priv->cqe_factor;
373 u64 timestamp = 0; 372 u64 timestamp = 0;
374 int done = 0; 373 int done = 0;
374 int budget = priv->tx_work_limit;
375 375
376 if (!priv->port_up) 376 if (!priv->port_up)
377 return 0; 377 return true;
378 378
379 index = cons_index & size_mask; 379 index = cons_index & size_mask;
380 cqe = &buf[(index << factor) + factor]; 380 cqe = &buf[(index << factor) + factor];
@@ -447,7 +447,7 @@ static int mlx4_en_process_tx_cq(struct net_device *dev,
447 netif_tx_wake_queue(ring->tx_queue); 447 netif_tx_wake_queue(ring->tx_queue);
448 ring->wake_queue++; 448 ring->wake_queue++;
449 } 449 }
450 return done; 450 return done < budget;
451} 451}
452 452
453void mlx4_en_tx_irq(struct mlx4_cq *mcq) 453void mlx4_en_tx_irq(struct mlx4_cq *mcq)
@@ -467,24 +467,16 @@ int mlx4_en_poll_tx_cq(struct napi_struct *napi, int budget)
467 struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi); 467 struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi);
468 struct net_device *dev = cq->dev; 468 struct net_device *dev = cq->dev;
469 struct mlx4_en_priv *priv = netdev_priv(dev); 469 struct mlx4_en_priv *priv = netdev_priv(dev);
470 int done; 470 int clean_complete;
471 471
472 done = mlx4_en_process_tx_cq(dev, cq, budget); 472 clean_complete = mlx4_en_process_tx_cq(dev, cq);
473 if (!clean_complete)
474 return budget;
473 475
474 /* If we used up all the quota - we're probably not done yet... */ 476 napi_complete(napi);
475 if (done < budget) { 477 mlx4_en_arm_cq(priv, cq);
476 /* Done for now */ 478
477 cq->mcq.irq_affinity_change = false; 479 return 0;
478 napi_complete(napi);
479 mlx4_en_arm_cq(priv, cq);
480 return done;
481 } else if (unlikely(cq->mcq.irq_affinity_change)) {
482 cq->mcq.irq_affinity_change = false;
483 napi_complete(napi);
484 mlx4_en_arm_cq(priv, cq);
485 return 0;
486 }
487 return budget;
488} 480}
489 481
490static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv, 482static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv,
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index d954ec1eac17..2a004b347e1d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -53,11 +53,6 @@ enum {
53 MLX4_EQ_ENTRY_SIZE = 0x20 53 MLX4_EQ_ENTRY_SIZE = 0x20
54}; 54};
55 55
56struct mlx4_irq_notify {
57 void *arg;
58 struct irq_affinity_notify notify;
59};
60
61#define MLX4_EQ_STATUS_OK ( 0 << 28) 56#define MLX4_EQ_STATUS_OK ( 0 << 28)
62#define MLX4_EQ_STATUS_WRITE_FAIL (10 << 28) 57#define MLX4_EQ_STATUS_WRITE_FAIL (10 << 28)
63#define MLX4_EQ_OWNER_SW ( 0 << 24) 58#define MLX4_EQ_OWNER_SW ( 0 << 24)
@@ -1088,57 +1083,6 @@ static void mlx4_unmap_clr_int(struct mlx4_dev *dev)
1088 iounmap(priv->clr_base); 1083 iounmap(priv->clr_base);
1089} 1084}
1090 1085
1091static void mlx4_irq_notifier_notify(struct irq_affinity_notify *notify,
1092 const cpumask_t *mask)
1093{
1094 struct mlx4_irq_notify *n = container_of(notify,
1095 struct mlx4_irq_notify,
1096 notify);
1097 struct mlx4_priv *priv = (struct mlx4_priv *)n->arg;
1098 struct radix_tree_iter iter;
1099 void **slot;
1100
1101 radix_tree_for_each_slot(slot, &priv->cq_table.tree, &iter, 0) {
1102 struct mlx4_cq *cq = (struct mlx4_cq *)(*slot);
1103
1104 if (cq->irq == notify->irq)
1105 cq->irq_affinity_change = true;
1106 }
1107}
1108
1109static void mlx4_release_irq_notifier(struct kref *ref)
1110{
1111 struct mlx4_irq_notify *n = container_of(ref, struct mlx4_irq_notify,
1112 notify.kref);
1113 kfree(n);
1114}
1115
1116static void mlx4_assign_irq_notifier(struct mlx4_priv *priv,
1117 struct mlx4_dev *dev, int irq)
1118{
1119 struct mlx4_irq_notify *irq_notifier = NULL;
1120 int err = 0;
1121
1122 irq_notifier = kzalloc(sizeof(*irq_notifier), GFP_KERNEL);
1123 if (!irq_notifier) {
1124 mlx4_warn(dev, "Failed to allocate irq notifier. irq %d\n",
1125 irq);
1126 return;
1127 }
1128
1129 irq_notifier->notify.irq = irq;
1130 irq_notifier->notify.notify = mlx4_irq_notifier_notify;
1131 irq_notifier->notify.release = mlx4_release_irq_notifier;
1132 irq_notifier->arg = priv;
1133 err = irq_set_affinity_notifier(irq, &irq_notifier->notify);
1134 if (err) {
1135 kfree(irq_notifier);
1136 irq_notifier = NULL;
1137 mlx4_warn(dev, "Failed to set irq notifier. irq %d\n", irq);
1138 }
1139}
1140
1141
1142int mlx4_alloc_eq_table(struct mlx4_dev *dev) 1086int mlx4_alloc_eq_table(struct mlx4_dev *dev)
1143{ 1087{
1144 struct mlx4_priv *priv = mlx4_priv(dev); 1088 struct mlx4_priv *priv = mlx4_priv(dev);
@@ -1409,8 +1353,6 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char *name, struct cpu_rmap *rmap,
1409 continue; 1353 continue;
1410 /*we dont want to break here*/ 1354 /*we dont want to break here*/
1411 } 1355 }
1412 mlx4_assign_irq_notifier(priv, dev,
1413 priv->eq_table.eq[vec].irq);
1414 1356
1415 eq_set_ci(&priv->eq_table.eq[vec], 1); 1357 eq_set_ci(&priv->eq_table.eq[vec], 1);
1416 } 1358 }
@@ -1427,6 +1369,14 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char *name, struct cpu_rmap *rmap,
1427} 1369}
1428EXPORT_SYMBOL(mlx4_assign_eq); 1370EXPORT_SYMBOL(mlx4_assign_eq);
1429 1371
1372int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec)
1373{
1374 struct mlx4_priv *priv = mlx4_priv(dev);
1375
1376 return priv->eq_table.eq[vec].irq;
1377}
1378EXPORT_SYMBOL(mlx4_eq_get_irq);
1379
1430void mlx4_release_eq(struct mlx4_dev *dev, int vec) 1380void mlx4_release_eq(struct mlx4_dev *dev, int vec)
1431{ 1381{
1432 struct mlx4_priv *priv = mlx4_priv(dev); 1382 struct mlx4_priv *priv = mlx4_priv(dev);
@@ -1438,9 +1388,6 @@ void mlx4_release_eq(struct mlx4_dev *dev, int vec)
1438 Belonging to a legacy EQ*/ 1388 Belonging to a legacy EQ*/
1439 mutex_lock(&priv->msix_ctl.pool_lock); 1389 mutex_lock(&priv->msix_ctl.pool_lock);
1440 if (priv->msix_ctl.pool_bm & 1ULL << i) { 1390 if (priv->msix_ctl.pool_bm & 1ULL << i) {
1441 irq_set_affinity_notifier(
1442 priv->eq_table.eq[vec].irq,
1443 NULL);
1444 free_irq(priv->eq_table.eq[vec].irq, 1391 free_irq(priv->eq_table.eq[vec].irq,
1445 &priv->eq_table.eq[vec]); 1392 &priv->eq_table.eq[vec]);
1446 priv->msix_ctl.pool_bm &= ~(1ULL << i); 1393 priv->msix_ctl.pool_bm &= ~(1ULL << i);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 5f42f6d6e4c6..82ab427290c3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2439,7 +2439,8 @@ slave_start:
2439 (num_vfs_argc > 1 || probe_vfs_argc > 1)) { 2439 (num_vfs_argc > 1 || probe_vfs_argc > 1)) {
2440 mlx4_err(dev, 2440 mlx4_err(dev,
2441 "Invalid syntax of num_vfs/probe_vfs with IB port - single port VFs syntax is only supported when all ports are configured as ethernet\n"); 2441 "Invalid syntax of num_vfs/probe_vfs with IB port - single port VFs syntax is only supported when all ports are configured as ethernet\n");
2442 goto err_close; 2442 err = -EINVAL;
2443 goto err_master_mfunc;
2443 } 2444 }
2444 for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); i++) { 2445 for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); i++) {
2445 unsigned j; 2446 unsigned j;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 0e15295bedd6..d72a5a894fc6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -126,6 +126,8 @@ enum {
126#define MAX_TX_RINGS (MLX4_EN_MAX_TX_RING_P_UP * \ 126#define MAX_TX_RINGS (MLX4_EN_MAX_TX_RING_P_UP * \
127 MLX4_EN_NUM_UP) 127 MLX4_EN_NUM_UP)
128 128
129#define MLX4_EN_DEFAULT_TX_WORK 256
130
129/* Target number of packets to coalesce with interrupt moderation */ 131/* Target number of packets to coalesce with interrupt moderation */
130#define MLX4_EN_RX_COAL_TARGET 44 132#define MLX4_EN_RX_COAL_TARGET 44
131#define MLX4_EN_RX_COAL_TIME 0x10 133#define MLX4_EN_RX_COAL_TIME 0x10
@@ -343,6 +345,7 @@ struct mlx4_en_cq {
343#define CQ_USER_PEND (MLX4_EN_CQ_STATE_POLL | MLX4_EN_CQ_STATE_POLL_YIELD) 345#define CQ_USER_PEND (MLX4_EN_CQ_STATE_POLL | MLX4_EN_CQ_STATE_POLL_YIELD)
344 spinlock_t poll_lock; /* protects from LLS/napi conflicts */ 346 spinlock_t poll_lock; /* protects from LLS/napi conflicts */
345#endif /* CONFIG_NET_RX_BUSY_POLL */ 347#endif /* CONFIG_NET_RX_BUSY_POLL */
348 struct irq_desc *irq_desc;
346}; 349};
347 350
348struct mlx4_en_port_profile { 351struct mlx4_en_port_profile {
@@ -542,6 +545,7 @@ struct mlx4_en_priv {
542 __be32 ctrl_flags; 545 __be32 ctrl_flags;
543 u32 flags; 546 u32 flags;
544 u8 num_tx_rings_p_up; 547 u8 num_tx_rings_p_up;
548 u32 tx_work_limit;
545 u32 tx_ring_num; 549 u32 tx_ring_num;
546 u32 rx_ring_num; 550 u32 rx_ring_num;
547 u32 rx_skb_size; 551 u32 rx_skb_size;
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index be425ad5e824..06bdc31a828d 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -538,6 +538,7 @@ enum rtl_register_content {
538 MagicPacket = (1 << 5), /* Wake up when receives a Magic Packet */ 538 MagicPacket = (1 << 5), /* Wake up when receives a Magic Packet */
539 LinkUp = (1 << 4), /* Wake up when the cable connection is re-established */ 539 LinkUp = (1 << 4), /* Wake up when the cable connection is re-established */
540 Jumbo_En0 = (1 << 2), /* 8168 only. Reserved in the 8168b */ 540 Jumbo_En0 = (1 << 2), /* 8168 only. Reserved in the 8168b */
541 Rdy_to_L23 = (1 << 1), /* L23 Enable */
541 Beacon_en = (1 << 0), /* 8168 only. Reserved in the 8168b */ 542 Beacon_en = (1 << 0), /* 8168 only. Reserved in the 8168b */
542 543
543 /* Config4 register */ 544 /* Config4 register */
@@ -4897,6 +4898,21 @@ static void rtl_enable_clock_request(struct pci_dev *pdev)
4897 PCI_EXP_LNKCTL_CLKREQ_EN); 4898 PCI_EXP_LNKCTL_CLKREQ_EN);
4898} 4899}
4899 4900
4901static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable)
4902{
4903 void __iomem *ioaddr = tp->mmio_addr;
4904 u8 data;
4905
4906 data = RTL_R8(Config3);
4907
4908 if (enable)
4909 data |= Rdy_to_L23;
4910 else
4911 data &= ~Rdy_to_L23;
4912
4913 RTL_W8(Config3, data);
4914}
4915
4900#define R8168_CPCMD_QUIRK_MASK (\ 4916#define R8168_CPCMD_QUIRK_MASK (\
4901 EnableBist | \ 4917 EnableBist | \
4902 Mac_dbgo_oe | \ 4918 Mac_dbgo_oe | \
@@ -5246,6 +5262,7 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp)
5246 }; 5262 };
5247 5263
5248 rtl_hw_start_8168f(tp); 5264 rtl_hw_start_8168f(tp);
5265 rtl_pcie_state_l2l3_enable(tp, false);
5249 5266
5250 rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); 5267 rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1));
5251 5268
@@ -5284,6 +5301,8 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
5284 5301
5285 rtl_w1w0_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC); 5302 rtl_w1w0_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC);
5286 rtl_w1w0_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC); 5303 rtl_w1w0_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC);
5304
5305 rtl_pcie_state_l2l3_enable(tp, false);
5287} 5306}
5288 5307
5289static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) 5308static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
@@ -5536,6 +5555,8 @@ static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
5536 RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN); 5555 RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
5537 5556
5538 rtl_ephy_init(tp, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); 5557 rtl_ephy_init(tp, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1));
5558
5559 rtl_pcie_state_l2l3_enable(tp, false);
5539} 5560}
5540 5561
5541static void rtl_hw_start_8105e_2(struct rtl8169_private *tp) 5562static void rtl_hw_start_8105e_2(struct rtl8169_private *tp)
@@ -5571,6 +5592,8 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp)
5571 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); 5592 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
5572 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); 5593 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
5573 rtl_w1w0_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0e00, 0xff00, ERIAR_EXGMAC); 5594 rtl_w1w0_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0e00, 0xff00, ERIAR_EXGMAC);
5595
5596 rtl_pcie_state_l2l3_enable(tp, false);
5574} 5597}
5575 5598
5576static void rtl_hw_start_8106(struct rtl8169_private *tp) 5599static void rtl_hw_start_8106(struct rtl8169_private *tp)
@@ -5583,6 +5606,8 @@ static void rtl_hw_start_8106(struct rtl8169_private *tp)
5583 RTL_W32(MISC, (RTL_R32(MISC) | DISABLE_LAN_EN) & ~EARLY_TALLY_EN); 5606 RTL_W32(MISC, (RTL_R32(MISC) | DISABLE_LAN_EN) & ~EARLY_TALLY_EN);
5584 RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); 5607 RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET);
5585 RTL_W8(DLLPR, RTL_R8(DLLPR) & ~PFM_EN); 5608 RTL_W8(DLLPR, RTL_R8(DLLPR) & ~PFM_EN);
5609
5610 rtl_pcie_state_l2l3_enable(tp, false);
5586} 5611}
5587 5612
5588static void rtl_hw_start_8101(struct net_device *dev) 5613static void rtl_hw_start_8101(struct net_device *dev)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index b3e148ef5683..9d3748361a1e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -320,11 +320,8 @@ static void dwmac1000_set_eee_timer(void __iomem *ioaddr, int ls, int tw)
320 320
321static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool restart) 321static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool restart)
322{ 322{
323 u32 value;
324
325 value = readl(ioaddr + GMAC_AN_CTRL);
326 /* auto negotiation enable and External Loopback enable */ 323 /* auto negotiation enable and External Loopback enable */
327 value = GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_ELE; 324 u32 value = GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_ELE;
328 325
329 if (restart) 326 if (restart)
330 value |= GMAC_AN_CTRL_RAN; 327 value |= GMAC_AN_CTRL_RAN;
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
index 7e6628a91514..1e2bcf5f89e1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
@@ -145,7 +145,7 @@ static void enh_desc_get_ext_status(void *data, struct stmmac_extra_stats *x,
145 x->rx_msg_type_delay_req++; 145 x->rx_msg_type_delay_req++;
146 else if (p->des4.erx.msg_type == RDES_EXT_DELAY_RESP) 146 else if (p->des4.erx.msg_type == RDES_EXT_DELAY_RESP)
147 x->rx_msg_type_delay_resp++; 147 x->rx_msg_type_delay_resp++;
148 else if (p->des4.erx.msg_type == RDES_EXT_DELAY_REQ) 148 else if (p->des4.erx.msg_type == RDES_EXT_PDELAY_REQ)
149 x->rx_msg_type_pdelay_req++; 149 x->rx_msg_type_pdelay_req++;
150 else if (p->des4.erx.msg_type == RDES_EXT_PDELAY_RESP) 150 else if (p->des4.erx.msg_type == RDES_EXT_PDELAY_RESP)
151 x->rx_msg_type_pdelay_resp++; 151 x->rx_msg_type_pdelay_resp++;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index ff380dac6629..b988d16cd34e 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1212,7 +1212,12 @@ static int cpsw_ndo_open(struct net_device *ndev)
1212 for_each_slave(priv, cpsw_slave_open, priv); 1212 for_each_slave(priv, cpsw_slave_open, priv);
1213 1213
1214 /* Add default VLAN */ 1214 /* Add default VLAN */
1215 cpsw_add_default_vlan(priv); 1215 if (!priv->data.dual_emac)
1216 cpsw_add_default_vlan(priv);
1217 else
1218 cpsw_ale_add_vlan(priv->ale, priv->data.default_vlan,
1219 ALE_ALL_PORTS << priv->host_port,
1220 ALE_ALL_PORTS << priv->host_port, 0, 0);
1216 1221
1217 if (!cpsw_common_res_usage_state(priv)) { 1222 if (!cpsw_common_res_usage_state(priv)) {
1218 /* setup tx dma to fixed prio and zero offset */ 1223 /* setup tx dma to fixed prio and zero offset */
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 14389f841d43..4c70360967c2 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -2191,7 +2191,6 @@ static void tile_net_setup(struct net_device *dev)
2191static void tile_net_dev_init(const char *name, const uint8_t *mac) 2191static void tile_net_dev_init(const char *name, const uint8_t *mac)
2192{ 2192{
2193 int ret; 2193 int ret;
2194 int i;
2195 struct net_device *dev; 2194 struct net_device *dev;
2196 struct tile_net_priv *priv; 2195 struct tile_net_priv *priv;
2197 2196
diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c
index eb78203cd58e..2aa57270838f 100644
--- a/drivers/net/fddi/defxx.c
+++ b/drivers/net/fddi/defxx.c
@@ -291,7 +291,11 @@ static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type);
291 291
292static int dfx_rcv_init(DFX_board_t *bp, int get_buffers); 292static int dfx_rcv_init(DFX_board_t *bp, int get_buffers);
293static void dfx_rcv_queue_process(DFX_board_t *bp); 293static void dfx_rcv_queue_process(DFX_board_t *bp);
294#ifdef DYNAMIC_BUFFERS
294static void dfx_rcv_flush(DFX_board_t *bp); 295static void dfx_rcv_flush(DFX_board_t *bp);
296#else
297static inline void dfx_rcv_flush(DFX_board_t *bp) {}
298#endif
295 299
296static netdev_tx_t dfx_xmt_queue_pkt(struct sk_buff *skb, 300static netdev_tx_t dfx_xmt_queue_pkt(struct sk_buff *skb,
297 struct net_device *dev); 301 struct net_device *dev);
@@ -2849,7 +2853,7 @@ static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type)
2849 * Align an sk_buff to a boundary power of 2 2853 * Align an sk_buff to a boundary power of 2
2850 * 2854 *
2851 */ 2855 */
2852 2856#ifdef DYNAMIC_BUFFERS
2853static void my_skb_align(struct sk_buff *skb, int n) 2857static void my_skb_align(struct sk_buff *skb, int n)
2854{ 2858{
2855 unsigned long x = (unsigned long)skb->data; 2859 unsigned long x = (unsigned long)skb->data;
@@ -2859,7 +2863,7 @@ static void my_skb_align(struct sk_buff *skb, int n)
2859 2863
2860 skb_reserve(skb, v - x); 2864 skb_reserve(skb, v - x);
2861} 2865}
2862 2866#endif
2863 2867
2864/* 2868/*
2865 * ================ 2869 * ================
@@ -3074,10 +3078,7 @@ static void dfx_rcv_queue_process(
3074 break; 3078 break;
3075 } 3079 }
3076 else { 3080 else {
3077#ifndef DYNAMIC_BUFFERS 3081 if (!rx_in_place) {
3078 if (! rx_in_place)
3079#endif
3080 {
3081 /* Receive buffer allocated, pass receive packet up */ 3082 /* Receive buffer allocated, pass receive packet up */
3082 3083
3083 skb_copy_to_linear_data(skb, 3084 skb_copy_to_linear_data(skb,
@@ -3453,10 +3454,6 @@ static void dfx_rcv_flush( DFX_board_t *bp )
3453 } 3454 }
3454 3455
3455 } 3456 }
3456#else
3457static inline void dfx_rcv_flush( DFX_board_t *bp )
3458{
3459}
3460#endif /* DYNAMIC_BUFFERS */ 3457#endif /* DYNAMIC_BUFFERS */
3461 3458
3462/* 3459/*
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index c041f63a6d30..4ed38eaecea8 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -189,7 +189,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
189 "unable to teardown send buffer's gpadl\n"); 189 "unable to teardown send buffer's gpadl\n");
190 return ret; 190 return ret;
191 } 191 }
192 net_device->recv_buf_gpadl_handle = 0; 192 net_device->send_buf_gpadl_handle = 0;
193 } 193 }
194 if (net_device->send_buf) { 194 if (net_device->send_buf) {
195 /* Free up the receive buffer */ 195 /* Free up the receive buffer */
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 4517b149ed07..50899416f668 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1137,6 +1137,8 @@ static int at86rf230_probe(struct spi_device *spi)
1137 dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK; 1137 dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;
1138 1138
1139 irq_type = irq_get_trigger_type(spi->irq); 1139 irq_type = irq_get_trigger_type(spi->irq);
1140 if (!irq_type)
1141 irq_type = IRQF_TRIGGER_RISING;
1140 if (irq_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) { 1142 if (irq_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) {
1141 irq_worker = at86rf230_irqwork; 1143 irq_worker = at86rf230_irqwork;
1142 irq_handler = at86rf230_isr; 1144 irq_handler = at86rf230_isr;
@@ -1168,7 +1170,8 @@ static int at86rf230_probe(struct spi_device *spi)
1168 if (rc) 1170 if (rc)
1169 goto err_hw_init; 1171 goto err_hw_init;
1170 1172
1171 rc = devm_request_irq(&spi->dev, spi->irq, irq_handler, IRQF_SHARED, 1173 rc = devm_request_irq(&spi->dev, spi->irq, irq_handler,
1174 IRQF_SHARED | irq_type,
1172 dev_name(&spi->dev), lp); 1175 dev_name(&spi->dev), lp);
1173 if (rc) 1176 if (rc)
1174 goto err_hw_init; 1177 goto err_hw_init;
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 6c622aedbae1..fdc1b418fa6a 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -16,9 +16,13 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/netdevice.h> 17#include <linux/netdevice.h>
18#include <linux/etherdevice.h> 18#include <linux/etherdevice.h>
19#include <linux/of_gpio.h>
20#include <linux/gpio/consumer.h>
19 21
20#define AT803X_INTR_ENABLE 0x12 22#define AT803X_INTR_ENABLE 0x12
21#define AT803X_INTR_STATUS 0x13 23#define AT803X_INTR_STATUS 0x13
24#define AT803X_SMART_SPEED 0x14
25#define AT803X_LED_CONTROL 0x18
22#define AT803X_WOL_ENABLE 0x01 26#define AT803X_WOL_ENABLE 0x01
23#define AT803X_DEVICE_ADDR 0x03 27#define AT803X_DEVICE_ADDR 0x03
24#define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C 28#define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C
@@ -35,10 +39,52 @@
35#define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05 39#define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05
36#define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8) 40#define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8)
37 41
42#define ATH8030_PHY_ID 0x004dd076
43#define ATH8031_PHY_ID 0x004dd074
44#define ATH8035_PHY_ID 0x004dd072
45
38MODULE_DESCRIPTION("Atheros 803x PHY driver"); 46MODULE_DESCRIPTION("Atheros 803x PHY driver");
39MODULE_AUTHOR("Matus Ujhelyi"); 47MODULE_AUTHOR("Matus Ujhelyi");
40MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
41 49
50struct at803x_priv {
51 bool phy_reset:1;
52 struct gpio_desc *gpiod_reset;
53};
54
55struct at803x_context {
56 u16 bmcr;
57 u16 advertise;
58 u16 control1000;
59 u16 int_enable;
60 u16 smart_speed;
61 u16 led_control;
62};
63
64/* save relevant PHY registers to private copy */
65static void at803x_context_save(struct phy_device *phydev,
66 struct at803x_context *context)
67{
68 context->bmcr = phy_read(phydev, MII_BMCR);
69 context->advertise = phy_read(phydev, MII_ADVERTISE);
70 context->control1000 = phy_read(phydev, MII_CTRL1000);
71 context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE);
72 context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED);
73 context->led_control = phy_read(phydev, AT803X_LED_CONTROL);
74}
75
76/* restore relevant PHY registers from private copy */
77static void at803x_context_restore(struct phy_device *phydev,
78 const struct at803x_context *context)
79{
80 phy_write(phydev, MII_BMCR, context->bmcr);
81 phy_write(phydev, MII_ADVERTISE, context->advertise);
82 phy_write(phydev, MII_CTRL1000, context->control1000);
83 phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable);
84 phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed);
85 phy_write(phydev, AT803X_LED_CONTROL, context->led_control);
86}
87
42static int at803x_set_wol(struct phy_device *phydev, 88static int at803x_set_wol(struct phy_device *phydev,
43 struct ethtool_wolinfo *wol) 89 struct ethtool_wolinfo *wol)
44{ 90{
@@ -142,6 +188,26 @@ static int at803x_resume(struct phy_device *phydev)
142 return 0; 188 return 0;
143} 189}
144 190
191static int at803x_probe(struct phy_device *phydev)
192{
193 struct device *dev = &phydev->dev;
194 struct at803x_priv *priv;
195
196 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
197 if (!priv)
198 return -ENOMEM;
199
200 priv->gpiod_reset = devm_gpiod_get(dev, "reset");
201 if (IS_ERR(priv->gpiod_reset))
202 priv->gpiod_reset = NULL;
203 else
204 gpiod_direction_output(priv->gpiod_reset, 1);
205
206 phydev->priv = priv;
207
208 return 0;
209}
210
145static int at803x_config_init(struct phy_device *phydev) 211static int at803x_config_init(struct phy_device *phydev)
146{ 212{
147 int ret; 213 int ret;
@@ -189,58 +255,99 @@ static int at803x_config_intr(struct phy_device *phydev)
189 return err; 255 return err;
190} 256}
191 257
258static void at803x_link_change_notify(struct phy_device *phydev)
259{
260 struct at803x_priv *priv = phydev->priv;
261
262 /*
263 * Conduct a hardware reset for AT8030 every time a link loss is
264 * signalled. This is necessary to circumvent a hardware bug that
265 * occurs when the cable is unplugged while TX packets are pending
266 * in the FIFO. In such cases, the FIFO enters an error mode it
267 * cannot recover from by software.
268 */
269 if (phydev->drv->phy_id == ATH8030_PHY_ID) {
270 if (phydev->state == PHY_NOLINK) {
271 if (priv->gpiod_reset && !priv->phy_reset) {
272 struct at803x_context context;
273
274 at803x_context_save(phydev, &context);
275
276 gpiod_set_value(priv->gpiod_reset, 0);
277 msleep(1);
278 gpiod_set_value(priv->gpiod_reset, 1);
279 msleep(1);
280
281 at803x_context_restore(phydev, &context);
282
283 dev_dbg(&phydev->dev, "%s(): phy was reset\n",
284 __func__);
285 priv->phy_reset = true;
286 }
287 } else {
288 priv->phy_reset = false;
289 }
290 }
291}
292
192static struct phy_driver at803x_driver[] = { 293static struct phy_driver at803x_driver[] = {
193{ 294{
194 /* ATHEROS 8035 */ 295 /* ATHEROS 8035 */
195 .phy_id = 0x004dd072, 296 .phy_id = ATH8035_PHY_ID,
196 .name = "Atheros 8035 ethernet", 297 .name = "Atheros 8035 ethernet",
197 .phy_id_mask = 0xffffffef, 298 .phy_id_mask = 0xffffffef,
198 .config_init = at803x_config_init, 299 .probe = at803x_probe,
199 .set_wol = at803x_set_wol, 300 .config_init = at803x_config_init,
200 .get_wol = at803x_get_wol, 301 .link_change_notify = at803x_link_change_notify,
201 .suspend = at803x_suspend, 302 .set_wol = at803x_set_wol,
202 .resume = at803x_resume, 303 .get_wol = at803x_get_wol,
203 .features = PHY_GBIT_FEATURES, 304 .suspend = at803x_suspend,
204 .flags = PHY_HAS_INTERRUPT, 305 .resume = at803x_resume,
205 .config_aneg = genphy_config_aneg, 306 .features = PHY_GBIT_FEATURES,
206 .read_status = genphy_read_status, 307 .flags = PHY_HAS_INTERRUPT,
207 .driver = { 308 .config_aneg = genphy_config_aneg,
309 .read_status = genphy_read_status,
310 .driver = {
208 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
209 }, 312 },
210}, { 313}, {
211 /* ATHEROS 8030 */ 314 /* ATHEROS 8030 */
212 .phy_id = 0x004dd076, 315 .phy_id = ATH8030_PHY_ID,
213 .name = "Atheros 8030 ethernet", 316 .name = "Atheros 8030 ethernet",
214 .phy_id_mask = 0xffffffef, 317 .phy_id_mask = 0xffffffef,
215 .config_init = at803x_config_init, 318 .probe = at803x_probe,
216 .set_wol = at803x_set_wol, 319 .config_init = at803x_config_init,
217 .get_wol = at803x_get_wol, 320 .link_change_notify = at803x_link_change_notify,
218 .suspend = at803x_suspend, 321 .set_wol = at803x_set_wol,
219 .resume = at803x_resume, 322 .get_wol = at803x_get_wol,
220 .features = PHY_GBIT_FEATURES, 323 .suspend = at803x_suspend,
221 .flags = PHY_HAS_INTERRUPT, 324 .resume = at803x_resume,
222 .config_aneg = genphy_config_aneg, 325 .features = PHY_GBIT_FEATURES,
223 .read_status = genphy_read_status, 326 .flags = PHY_HAS_INTERRUPT,
224 .driver = { 327 .config_aneg = genphy_config_aneg,
328 .read_status = genphy_read_status,
329 .driver = {
225 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
226 }, 331 },
227}, { 332}, {
228 /* ATHEROS 8031 */ 333 /* ATHEROS 8031 */
229 .phy_id = 0x004dd074, 334 .phy_id = ATH8031_PHY_ID,
230 .name = "Atheros 8031 ethernet", 335 .name = "Atheros 8031 ethernet",
231 .phy_id_mask = 0xffffffef, 336 .phy_id_mask = 0xffffffef,
232 .config_init = at803x_config_init, 337 .probe = at803x_probe,
233 .set_wol = at803x_set_wol, 338 .config_init = at803x_config_init,
234 .get_wol = at803x_get_wol, 339 .link_change_notify = at803x_link_change_notify,
235 .suspend = at803x_suspend, 340 .set_wol = at803x_set_wol,
236 .resume = at803x_resume, 341 .get_wol = at803x_get_wol,
237 .features = PHY_GBIT_FEATURES, 342 .suspend = at803x_suspend,
238 .flags = PHY_HAS_INTERRUPT, 343 .resume = at803x_resume,
239 .config_aneg = genphy_config_aneg, 344 .features = PHY_GBIT_FEATURES,
240 .read_status = genphy_read_status, 345 .flags = PHY_HAS_INTERRUPT,
241 .ack_interrupt = &at803x_ack_interrupt, 346 .config_aneg = genphy_config_aneg,
242 .config_intr = &at803x_config_intr, 347 .read_status = genphy_read_status,
243 .driver = { 348 .ack_interrupt = &at803x_ack_interrupt,
349 .config_intr = &at803x_config_intr,
350 .driver = {
244 .owner = THIS_MODULE, 351 .owner = THIS_MODULE,
245 }, 352 },
246} }; 353} };
@@ -260,9 +367,9 @@ module_init(atheros_init);
260module_exit(atheros_exit); 367module_exit(atheros_exit);
261 368
262static struct mdio_device_id __maybe_unused atheros_tbl[] = { 369static struct mdio_device_id __maybe_unused atheros_tbl[] = {
263 { 0x004dd076, 0xffffffef }, 370 { ATH8030_PHY_ID, 0xffffffef },
264 { 0x004dd074, 0xffffffef }, 371 { ATH8031_PHY_ID, 0xffffffef },
265 { 0x004dd072, 0xffffffef }, 372 { ATH8035_PHY_ID, 0xffffffef },
266 { } 373 { }
267}; 374};
268 375
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 6a999e6814a0..9408157a246c 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1323,15 +1323,15 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
1323{ 1323{
1324 struct dp83640_private *dp83640 = phydev->priv; 1324 struct dp83640_private *dp83640 = phydev->priv;
1325 1325
1326 if (!dp83640->hwts_rx_en)
1327 return false;
1328
1329 if (is_status_frame(skb, type)) { 1326 if (is_status_frame(skb, type)) {
1330 decode_status_frame(dp83640, skb); 1327 decode_status_frame(dp83640, skb);
1331 kfree_skb(skb); 1328 kfree_skb(skb);
1332 return true; 1329 return true;
1333 } 1330 }
1334 1331
1332 if (!dp83640->hwts_rx_en)
1333 return false;
1334
1335 SKB_PTP_TYPE(skb) = type; 1335 SKB_PTP_TYPE(skb) = type;
1336 skb_queue_tail(&dp83640->rx_queue, skb); 1336 skb_queue_tail(&dp83640->rx_queue, skb);
1337 schedule_work(&dp83640->ts_work); 1337 schedule_work(&dp83640->ts_work);
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 2e58aa54484c..4eaadcfcb0fe 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -187,6 +187,50 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
187 return d ? to_mii_bus(d) : NULL; 187 return d ? to_mii_bus(d) : NULL;
188} 188}
189EXPORT_SYMBOL(of_mdio_find_bus); 189EXPORT_SYMBOL(of_mdio_find_bus);
190
191/* Walk the list of subnodes of a mdio bus and look for a node that matches the
192 * phy's address with its 'reg' property. If found, set the of_node pointer for
193 * the phy. This allows auto-probed pyh devices to be supplied with information
194 * passed in via DT.
195 */
196static void of_mdiobus_link_phydev(struct mii_bus *mdio,
197 struct phy_device *phydev)
198{
199 struct device *dev = &phydev->dev;
200 struct device_node *child;
201
202 if (dev->of_node || !mdio->dev.of_node)
203 return;
204
205 for_each_available_child_of_node(mdio->dev.of_node, child) {
206 int addr;
207 int ret;
208
209 ret = of_property_read_u32(child, "reg", &addr);
210 if (ret < 0) {
211 dev_err(dev, "%s has invalid PHY address\n",
212 child->full_name);
213 continue;
214 }
215
216 /* A PHY must have a reg property in the range [0-31] */
217 if (addr >= PHY_MAX_ADDR) {
218 dev_err(dev, "%s PHY address %i is too large\n",
219 child->full_name, addr);
220 continue;
221 }
222
223 if (addr == phydev->addr) {
224 dev->of_node = child;
225 return;
226 }
227 }
228}
229#else /* !IS_ENABLED(CONFIG_OF_MDIO) */
230static inline void of_mdiobus_link_phydev(struct mii_bus *mdio,
231 struct phy_device *phydev)
232{
233}
190#endif 234#endif
191 235
192/** 236/**
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 3bc079a67a3d..f7c61812ea4a 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -720,6 +720,9 @@ void phy_state_machine(struct work_struct *work)
720 720
721 mutex_lock(&phydev->lock); 721 mutex_lock(&phydev->lock);
722 722
723 if (phydev->drv->link_change_notify)
724 phydev->drv->link_change_notify(phydev);
725
723 switch (phydev->state) { 726 switch (phydev->state) {
724 case PHY_DOWN: 727 case PHY_DOWN:
725 case PHY_STARTING: 728 case PHY_STARTING:
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 91d6c1272fcf..e2f20f807de8 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -539,7 +539,7 @@ static int get_filter(void __user *arg, struct sock_filter **p)
539{ 539{
540 struct sock_fprog uprog; 540 struct sock_fprog uprog;
541 struct sock_filter *code = NULL; 541 struct sock_filter *code = NULL;
542 int len, err; 542 int len;
543 543
544 if (copy_from_user(&uprog, arg, sizeof(uprog))) 544 if (copy_from_user(&uprog, arg, sizeof(uprog)))
545 return -EFAULT; 545 return -EFAULT;
@@ -554,12 +554,6 @@ static int get_filter(void __user *arg, struct sock_filter **p)
554 if (IS_ERR(code)) 554 if (IS_ERR(code))
555 return PTR_ERR(code); 555 return PTR_ERR(code);
556 556
557 err = sk_chk_filter(code, uprog.len);
558 if (err) {
559 kfree(code);
560 return err;
561 }
562
563 *p = code; 557 *p = code;
564 return uprog.len; 558 return uprog.len;
565} 559}
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index 2ea7efd11857..6c9c16d76935 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -675,7 +675,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr,
675 po->chan.hdrlen = (sizeof(struct pppoe_hdr) + 675 po->chan.hdrlen = (sizeof(struct pppoe_hdr) +
676 dev->hard_header_len); 676 dev->hard_header_len);
677 677
678 po->chan.mtu = dev->mtu - sizeof(struct pppoe_hdr); 678 po->chan.mtu = dev->mtu - sizeof(struct pppoe_hdr) - 2;
679 po->chan.private = sk; 679 po->chan.private = sk;
680 po->chan.ops = &pppoe_chan_ops; 680 po->chan.ops = &pppoe_chan_ops;
681 681
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index ad4a94e9ff57..87526443841f 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -83,6 +83,7 @@
83#include <linux/delay.h> 83#include <linux/delay.h>
84#include <linux/init.h> 84#include <linux/init.h>
85#include <linux/slab.h> 85#include <linux/slab.h>
86#include <linux/workqueue.h>
86#include "slip.h" 87#include "slip.h"
87#ifdef CONFIG_INET 88#ifdef CONFIG_INET
88#include <linux/ip.h> 89#include <linux/ip.h>
@@ -416,36 +417,46 @@ static void sl_encaps(struct slip *sl, unsigned char *icp, int len)
416#endif 417#endif
417} 418}
418 419
419/* 420/* Write out any remaining transmit buffer. Scheduled when tty is writable */
420 * Called by the driver when there's room for more data. If we have 421static void slip_transmit(struct work_struct *work)
421 * more packets to send, we send them here.
422 */
423static void slip_write_wakeup(struct tty_struct *tty)
424{ 422{
423 struct slip *sl = container_of(work, struct slip, tx_work);
425 int actual; 424 int actual;
426 struct slip *sl = tty->disc_data;
427 425
426 spin_lock_bh(&sl->lock);
428 /* First make sure we're connected. */ 427 /* First make sure we're connected. */
429 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) 428 if (!sl->tty || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) {
429 spin_unlock_bh(&sl->lock);
430 return; 430 return;
431 }
431 432
432 spin_lock_bh(&sl->lock);
433 if (sl->xleft <= 0) { 433 if (sl->xleft <= 0) {
434 /* Now serial buffer is almost free & we can start 434 /* Now serial buffer is almost free & we can start
435 * transmission of another packet */ 435 * transmission of another packet */
436 sl->dev->stats.tx_packets++; 436 sl->dev->stats.tx_packets++;
437 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 437 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
438 spin_unlock_bh(&sl->lock); 438 spin_unlock_bh(&sl->lock);
439 sl_unlock(sl); 439 sl_unlock(sl);
440 return; 440 return;
441 } 441 }
442 442
443 actual = tty->ops->write(tty, sl->xhead, sl->xleft); 443 actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft);
444 sl->xleft -= actual; 444 sl->xleft -= actual;
445 sl->xhead += actual; 445 sl->xhead += actual;
446 spin_unlock_bh(&sl->lock); 446 spin_unlock_bh(&sl->lock);
447} 447}
448 448
449/*
450 * Called by the driver when there's room for more data.
451 * Schedule the transmit.
452 */
453static void slip_write_wakeup(struct tty_struct *tty)
454{
455 struct slip *sl = tty->disc_data;
456
457 schedule_work(&sl->tx_work);
458}
459
449static void sl_tx_timeout(struct net_device *dev) 460static void sl_tx_timeout(struct net_device *dev)
450{ 461{
451 struct slip *sl = netdev_priv(dev); 462 struct slip *sl = netdev_priv(dev);
@@ -749,6 +760,7 @@ static struct slip *sl_alloc(dev_t line)
749 sl->magic = SLIP_MAGIC; 760 sl->magic = SLIP_MAGIC;
750 sl->dev = dev; 761 sl->dev = dev;
751 spin_lock_init(&sl->lock); 762 spin_lock_init(&sl->lock);
763 INIT_WORK(&sl->tx_work, slip_transmit);
752 sl->mode = SL_MODE_DEFAULT; 764 sl->mode = SL_MODE_DEFAULT;
753#ifdef CONFIG_SLIP_SMART 765#ifdef CONFIG_SLIP_SMART
754 /* initialize timer_list struct */ 766 /* initialize timer_list struct */
@@ -872,8 +884,12 @@ static void slip_close(struct tty_struct *tty)
872 if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty) 884 if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty)
873 return; 885 return;
874 886
887 spin_lock_bh(&sl->lock);
875 tty->disc_data = NULL; 888 tty->disc_data = NULL;
876 sl->tty = NULL; 889 sl->tty = NULL;
890 spin_unlock_bh(&sl->lock);
891
892 flush_work(&sl->tx_work);
877 893
878 /* VSV = very important to remove timers */ 894 /* VSV = very important to remove timers */
879#ifdef CONFIG_SLIP_SMART 895#ifdef CONFIG_SLIP_SMART
diff --git a/drivers/net/slip/slip.h b/drivers/net/slip/slip.h
index 67673cf1266b..cf32aadf508f 100644
--- a/drivers/net/slip/slip.h
+++ b/drivers/net/slip/slip.h
@@ -53,6 +53,7 @@ struct slip {
53 struct tty_struct *tty; /* ptr to TTY structure */ 53 struct tty_struct *tty; /* ptr to TTY structure */
54 struct net_device *dev; /* easy for intr handling */ 54 struct net_device *dev; /* easy for intr handling */
55 spinlock_t lock; 55 spinlock_t lock;
56 struct work_struct tx_work; /* Flushes transmit buffer */
56 57
57#ifdef SL_INCLUDE_CSLIP 58#ifdef SL_INCLUDE_CSLIP
58 struct slcompress *slcomp; /* for header compression */ 59 struct slcompress *slcomp; /* for header compression */
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index a3a05869309d..a4272ed62da8 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -258,10 +258,8 @@ struct hso_serial {
258 * so as not to drop characters on the floor. 258 * so as not to drop characters on the floor.
259 */ 259 */
260 int curr_rx_urb_idx; 260 int curr_rx_urb_idx;
261 u16 curr_rx_urb_offset;
262 u8 rx_urb_filled[MAX_RX_URBS]; 261 u8 rx_urb_filled[MAX_RX_URBS];
263 struct tasklet_struct unthrottle_tasklet; 262 struct tasklet_struct unthrottle_tasklet;
264 struct work_struct retry_unthrottle_workqueue;
265}; 263};
266 264
267struct hso_device { 265struct hso_device {
@@ -1252,14 +1250,6 @@ static void hso_unthrottle(struct tty_struct *tty)
1252 tasklet_hi_schedule(&serial->unthrottle_tasklet); 1250 tasklet_hi_schedule(&serial->unthrottle_tasklet);
1253} 1251}
1254 1252
1255static void hso_unthrottle_workfunc(struct work_struct *work)
1256{
1257 struct hso_serial *serial =
1258 container_of(work, struct hso_serial,
1259 retry_unthrottle_workqueue);
1260 hso_unthrottle_tasklet(serial);
1261}
1262
1263/* open the requested serial port */ 1253/* open the requested serial port */
1264static int hso_serial_open(struct tty_struct *tty, struct file *filp) 1254static int hso_serial_open(struct tty_struct *tty, struct file *filp)
1265{ 1255{
@@ -1295,8 +1285,6 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
1295 tasklet_init(&serial->unthrottle_tasklet, 1285 tasklet_init(&serial->unthrottle_tasklet,
1296 (void (*)(unsigned long))hso_unthrottle_tasklet, 1286 (void (*)(unsigned long))hso_unthrottle_tasklet,
1297 (unsigned long)serial); 1287 (unsigned long)serial);
1298 INIT_WORK(&serial->retry_unthrottle_workqueue,
1299 hso_unthrottle_workfunc);
1300 result = hso_start_serial_device(serial->parent, GFP_KERNEL); 1288 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
1301 if (result) { 1289 if (result) {
1302 hso_stop_serial_device(serial->parent); 1290 hso_stop_serial_device(serial->parent);
@@ -1345,7 +1333,6 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
1345 if (!usb_gone) 1333 if (!usb_gone)
1346 hso_stop_serial_device(serial->parent); 1334 hso_stop_serial_device(serial->parent);
1347 tasklet_kill(&serial->unthrottle_tasklet); 1335 tasklet_kill(&serial->unthrottle_tasklet);
1348 cancel_work_sync(&serial->retry_unthrottle_workqueue);
1349 } 1336 }
1350 1337
1351 if (!usb_gone) 1338 if (!usb_gone)
@@ -2013,8 +2000,7 @@ static void ctrl_callback(struct urb *urb)
2013static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) 2000static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
2014{ 2001{
2015 struct tty_struct *tty; 2002 struct tty_struct *tty;
2016 int write_length_remaining = 0; 2003 int count;
2017 int curr_write_len;
2018 2004
2019 /* Sanity check */ 2005 /* Sanity check */
2020 if (urb == NULL || serial == NULL) { 2006 if (urb == NULL || serial == NULL) {
@@ -2024,29 +2010,28 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
2024 2010
2025 tty = tty_port_tty_get(&serial->port); 2011 tty = tty_port_tty_get(&serial->port);
2026 2012
2013 if (tty && test_bit(TTY_THROTTLED, &tty->flags)) {
2014 tty_kref_put(tty);
2015 return -1;
2016 }
2017
2027 /* Push data to tty */ 2018 /* Push data to tty */
2028 write_length_remaining = urb->actual_length -
2029 serial->curr_rx_urb_offset;
2030 D1("data to push to tty"); 2019 D1("data to push to tty");
2031 while (write_length_remaining) { 2020 count = tty_buffer_request_room(&serial->port, urb->actual_length);
2032 if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { 2021 if (count >= urb->actual_length) {
2033 tty_kref_put(tty); 2022 tty_insert_flip_string(&serial->port, urb->transfer_buffer,
2034 return -1; 2023 urb->actual_length);
2035 }
2036 curr_write_len = tty_insert_flip_string(&serial->port,
2037 urb->transfer_buffer + serial->curr_rx_urb_offset,
2038 write_length_remaining);
2039 serial->curr_rx_urb_offset += curr_write_len;
2040 write_length_remaining -= curr_write_len;
2041 tty_flip_buffer_push(&serial->port); 2024 tty_flip_buffer_push(&serial->port);
2025 } else {
2026 dev_warn(&serial->parent->usb->dev,
2027 "dropping data, %d bytes lost\n", urb->actual_length);
2042 } 2028 }
2029
2043 tty_kref_put(tty); 2030 tty_kref_put(tty);
2044 2031
2045 if (write_length_remaining == 0) { 2032 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0;
2046 serial->curr_rx_urb_offset = 0; 2033
2047 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; 2034 return 0;
2048 }
2049 return write_length_remaining;
2050} 2035}
2051 2036
2052 2037
@@ -2217,7 +2202,6 @@ static int hso_stop_serial_device(struct hso_device *hso_dev)
2217 } 2202 }
2218 } 2203 }
2219 serial->curr_rx_urb_idx = 0; 2204 serial->curr_rx_urb_idx = 0;
2220 serial->curr_rx_urb_offset = 0;
2221 2205
2222 if (serial->tx_urb) 2206 if (serial->tx_urb)
2223 usb_kill_urb(serial->tx_urb); 2207 usb_kill_urb(serial->tx_urb);
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c
index f9822bc75425..5d95a13dbe2a 100644
--- a/drivers/net/usb/huawei_cdc_ncm.c
+++ b/drivers/net/usb/huawei_cdc_ncm.c
@@ -84,12 +84,13 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
84 ctx = drvstate->ctx; 84 ctx = drvstate->ctx;
85 85
86 if (usbnet_dev->status) 86 if (usbnet_dev->status)
87 /* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 87 /* The wMaxCommand buffer must be big enough to hold
88 * decimal (0x100)" 88 * any message from the modem. Experience has shown
89 * that some replies are more than 256 bytes long
89 */ 90 */
90 subdriver = usb_cdc_wdm_register(ctx->control, 91 subdriver = usb_cdc_wdm_register(ctx->control,
91 &usbnet_dev->status->desc, 92 &usbnet_dev->status->desc,
92 256, /* wMaxCommand */ 93 1024, /* wMaxCommand */
93 huawei_cdc_ncm_wdm_manage_power); 94 huawei_cdc_ncm_wdm_manage_power);
94 if (IS_ERR(subdriver)) { 95 if (IS_ERR(subdriver)) {
95 ret = PTR_ERR(subdriver); 96 ret = PTR_ERR(subdriver);
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index cf62d7e8329f..c4638c67f6b9 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -741,6 +741,7 @@ static const struct usb_device_id products[] = {
741 {QMI_FIXED_INTF(0x19d2, 0x1424, 2)}, 741 {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
742 {QMI_FIXED_INTF(0x19d2, 0x1425, 2)}, 742 {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
743 {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */ 743 {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */
744 {QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */
744 {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ 745 {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
745 {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ 746 {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
746 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ 747 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 25431965a625..7bad2d316637 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1359,7 +1359,7 @@ static void r8152_csum_workaround(struct r8152 *tp, struct sk_buff *skb,
1359 struct sk_buff_head seg_list; 1359 struct sk_buff_head seg_list;
1360 struct sk_buff *segs, *nskb; 1360 struct sk_buff *segs, *nskb;
1361 1361
1362 features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO); 1362 features &= ~(NETIF_F_SG | NETIF_F_IPV6_CSUM | NETIF_F_TSO6);
1363 segs = skb_gso_segment(skb, features); 1363 segs = skb_gso_segment(skb, features);
1364 if (IS_ERR(segs) || !segs) 1364 if (IS_ERR(segs) || !segs)
1365 goto drop; 1365 goto drop;
@@ -3204,8 +3204,13 @@ static void rtl8152_get_ethtool_stats(struct net_device *dev,
3204 struct r8152 *tp = netdev_priv(dev); 3204 struct r8152 *tp = netdev_priv(dev);
3205 struct tally_counter tally; 3205 struct tally_counter tally;
3206 3206
3207 if (usb_autopm_get_interface(tp->intf) < 0)
3208 return;
3209
3207 generic_ocp_read(tp, PLA_TALLYCNT, sizeof(tally), &tally, MCU_TYPE_PLA); 3210 generic_ocp_read(tp, PLA_TALLYCNT, sizeof(tally), &tally, MCU_TYPE_PLA);
3208 3211
3212 usb_autopm_put_interface(tp->intf);
3213
3209 data[0] = le64_to_cpu(tally.tx_packets); 3214 data[0] = le64_to_cpu(tally.tx_packets);
3210 data[1] = le64_to_cpu(tally.rx_packets); 3215 data[1] = le64_to_cpu(tally.rx_packets);
3211 data[2] = le64_to_cpu(tally.tx_errors); 3216 data[2] = le64_to_cpu(tally.tx_errors);
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 424db65e4396..d07bf4cb893f 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1714,6 +1714,18 @@ static int smsc95xx_resume(struct usb_interface *intf)
1714 return ret; 1714 return ret;
1715} 1715}
1716 1716
1717static int smsc95xx_reset_resume(struct usb_interface *intf)
1718{
1719 struct usbnet *dev = usb_get_intfdata(intf);
1720 int ret;
1721
1722 ret = smsc95xx_reset(dev);
1723 if (ret < 0)
1724 return ret;
1725
1726 return smsc95xx_resume(intf);
1727}
1728
1717static void smsc95xx_rx_csum_offload(struct sk_buff *skb) 1729static void smsc95xx_rx_csum_offload(struct sk_buff *skb)
1718{ 1730{
1719 skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); 1731 skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2);
@@ -2004,7 +2016,7 @@ static struct usb_driver smsc95xx_driver = {
2004 .probe = usbnet_probe, 2016 .probe = usbnet_probe,
2005 .suspend = smsc95xx_suspend, 2017 .suspend = smsc95xx_suspend,
2006 .resume = smsc95xx_resume, 2018 .resume = smsc95xx_resume,
2007 .reset_resume = smsc95xx_resume, 2019 .reset_resume = smsc95xx_reset_resume,
2008 .disconnect = usbnet_disconnect, 2020 .disconnect = usbnet_disconnect,
2009 .disable_hub_initiated_lpm = 1, 2021 .disable_hub_initiated_lpm = 1,
2010 .supports_autosuspend = 1, 2022 .supports_autosuspend = 1,
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 97394345e5dd..b76f7dcde0db 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2589,8 +2589,8 @@ vmxnet3_open(struct net_device *netdev)
2589 for (i = 0; i < adapter->num_tx_queues; i++) 2589 for (i = 0; i < adapter->num_tx_queues; i++)
2590 spin_lock_init(&adapter->tx_queue[i].tx_lock); 2590 spin_lock_init(&adapter->tx_queue[i].tx_lock);
2591 2591
2592 err = vmxnet3_create_queues(adapter, VMXNET3_DEF_TX_RING_SIZE, 2592 err = vmxnet3_create_queues(adapter, adapter->tx_ring_size,
2593 VMXNET3_DEF_RX_RING_SIZE, 2593 adapter->rx_ring_size,
2594 VMXNET3_DEF_RX_RING_SIZE); 2594 VMXNET3_DEF_RX_RING_SIZE);
2595 if (err) 2595 if (err)
2596 goto queue_err; 2596 goto queue_err;
@@ -2968,6 +2968,9 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2968 adapter->netdev = netdev; 2968 adapter->netdev = netdev;
2969 adapter->pdev = pdev; 2969 adapter->pdev = pdev;
2970 2970
2971 adapter->tx_ring_size = VMXNET3_DEF_TX_RING_SIZE;
2972 adapter->rx_ring_size = VMXNET3_DEF_RX_RING_SIZE;
2973
2971 spin_lock_init(&adapter->cmd_lock); 2974 spin_lock_init(&adapter->cmd_lock);
2972 adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter, 2975 adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter,
2973 sizeof(struct vmxnet3_adapter), 2976 sizeof(struct vmxnet3_adapter),
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 40c1c7b0d9e0..b725fd9e7803 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -449,8 +449,8 @@ vmxnet3_get_ringparam(struct net_device *netdev,
449 param->rx_mini_max_pending = 0; 449 param->rx_mini_max_pending = 0;
450 param->rx_jumbo_max_pending = 0; 450 param->rx_jumbo_max_pending = 0;
451 451
452 param->rx_pending = adapter->rx_queue[0].rx_ring[0].size; 452 param->rx_pending = adapter->rx_ring_size;
453 param->tx_pending = adapter->tx_queue[0].tx_ring.size; 453 param->tx_pending = adapter->tx_ring_size;
454 param->rx_mini_pending = 0; 454 param->rx_mini_pending = 0;
455 param->rx_jumbo_pending = 0; 455 param->rx_jumbo_pending = 0;
456} 456}
@@ -529,9 +529,11 @@ vmxnet3_set_ringparam(struct net_device *netdev,
529 * size */ 529 * size */
530 netdev_err(netdev, "failed to apply new sizes, " 530 netdev_err(netdev, "failed to apply new sizes, "
531 "try the default ones\n"); 531 "try the default ones\n");
532 new_rx_ring_size = VMXNET3_DEF_RX_RING_SIZE;
533 new_tx_ring_size = VMXNET3_DEF_TX_RING_SIZE;
532 err = vmxnet3_create_queues(adapter, 534 err = vmxnet3_create_queues(adapter,
533 VMXNET3_DEF_TX_RING_SIZE, 535 new_tx_ring_size,
534 VMXNET3_DEF_RX_RING_SIZE, 536 new_rx_ring_size,
535 VMXNET3_DEF_RX_RING_SIZE); 537 VMXNET3_DEF_RX_RING_SIZE);
536 if (err) { 538 if (err) {
537 netdev_err(netdev, "failed to create queues " 539 netdev_err(netdev, "failed to create queues "
@@ -545,6 +547,8 @@ vmxnet3_set_ringparam(struct net_device *netdev,
545 netdev_err(netdev, "failed to re-activate, error %d." 547 netdev_err(netdev, "failed to re-activate, error %d."
546 " Closing it\n", err); 548 " Closing it\n", err);
547 } 549 }
550 adapter->tx_ring_size = new_tx_ring_size;
551 adapter->rx_ring_size = new_rx_ring_size;
548 552
549out: 553out:
550 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); 554 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index 190569d02450..29ee77f2c97f 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -349,6 +349,11 @@ struct vmxnet3_adapter {
349 u32 link_speed; /* in mbps */ 349 u32 link_speed; /* in mbps */
350 350
351 u64 tx_timeout_count; 351 u64 tx_timeout_count;
352
353 /* Ring sizes */
354 u32 tx_ring_size;
355 u32 rx_ring_size;
356
352 struct work_struct work; 357 struct work_struct work;
353 358
354 unsigned long state; /* VMXNET3_STATE_BIT_xxx */ 359 unsigned long state; /* VMXNET3_STATE_BIT_xxx */
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 93ace042d0aa..1f041271f7fe 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -2363,7 +2363,7 @@ static char *type_strings[] = {
2363 "FarSync TE1" 2363 "FarSync TE1"
2364}; 2364};
2365 2365
2366static void 2366static int
2367fst_init_card(struct fst_card_info *card) 2367fst_init_card(struct fst_card_info *card)
2368{ 2368{
2369 int i; 2369 int i;
@@ -2374,24 +2374,21 @@ fst_init_card(struct fst_card_info *card)
2374 * we'll have to revise it in some way then. 2374 * we'll have to revise it in some way then.
2375 */ 2375 */
2376 for (i = 0; i < card->nports; i++) { 2376 for (i = 0; i < card->nports; i++) {
2377 err = register_hdlc_device(card->ports[i].dev); 2377 err = register_hdlc_device(card->ports[i].dev);
2378 if (err < 0) { 2378 if (err < 0) {
2379 int j;
2380 pr_err("Cannot register HDLC device for port %d (errno %d)\n", 2379 pr_err("Cannot register HDLC device for port %d (errno %d)\n",
2381 i, -err); 2380 i, -err);
2382 for (j = i; j < card->nports; j++) { 2381 while (i--)
2383 free_netdev(card->ports[j].dev); 2382 unregister_hdlc_device(card->ports[i].dev);
2384 card->ports[j].dev = NULL; 2383 return err;
2385 } 2384 }
2386 card->nports = i;
2387 break;
2388 }
2389 } 2385 }
2390 2386
2391 pr_info("%s-%s: %s IRQ%d, %d ports\n", 2387 pr_info("%s-%s: %s IRQ%d, %d ports\n",
2392 port_to_dev(&card->ports[0])->name, 2388 port_to_dev(&card->ports[0])->name,
2393 port_to_dev(&card->ports[card->nports - 1])->name, 2389 port_to_dev(&card->ports[card->nports - 1])->name,
2394 type_strings[card->type], card->irq, card->nports); 2390 type_strings[card->type], card->irq, card->nports);
2391 return 0;
2395} 2392}
2396 2393
2397static const struct net_device_ops fst_ops = { 2394static const struct net_device_ops fst_ops = {
@@ -2447,15 +2444,12 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2447 /* Try to enable the device */ 2444 /* Try to enable the device */
2448 if ((err = pci_enable_device(pdev)) != 0) { 2445 if ((err = pci_enable_device(pdev)) != 0) {
2449 pr_err("Failed to enable card. Err %d\n", -err); 2446 pr_err("Failed to enable card. Err %d\n", -err);
2450 kfree(card); 2447 goto enable_fail;
2451 return err;
2452 } 2448 }
2453 2449
2454 if ((err = pci_request_regions(pdev, "FarSync")) !=0) { 2450 if ((err = pci_request_regions(pdev, "FarSync")) !=0) {
2455 pr_err("Failed to allocate regions. Err %d\n", -err); 2451 pr_err("Failed to allocate regions. Err %d\n", -err);
2456 pci_disable_device(pdev); 2452 goto regions_fail;
2457 kfree(card);
2458 return err;
2459 } 2453 }
2460 2454
2461 /* Get virtual addresses of memory regions */ 2455 /* Get virtual addresses of memory regions */
@@ -2464,30 +2458,21 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2464 card->phys_ctlmem = pci_resource_start(pdev, 3); 2458 card->phys_ctlmem = pci_resource_start(pdev, 3);
2465 if ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) { 2459 if ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) {
2466 pr_err("Physical memory remap failed\n"); 2460 pr_err("Physical memory remap failed\n");
2467 pci_release_regions(pdev); 2461 err = -ENODEV;
2468 pci_disable_device(pdev); 2462 goto ioremap_physmem_fail;
2469 kfree(card);
2470 return -ENODEV;
2471 } 2463 }
2472 if ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) { 2464 if ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) {
2473 pr_err("Control memory remap failed\n"); 2465 pr_err("Control memory remap failed\n");
2474 pci_release_regions(pdev); 2466 err = -ENODEV;
2475 pci_disable_device(pdev); 2467 goto ioremap_ctlmem_fail;
2476 iounmap(card->mem);
2477 kfree(card);
2478 return -ENODEV;
2479 } 2468 }
2480 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); 2469 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem);
2481 2470
2482 /* Register the interrupt handler */ 2471 /* Register the interrupt handler */
2483 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { 2472 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) {
2484 pr_err("Unable to register interrupt %d\n", card->irq); 2473 pr_err("Unable to register interrupt %d\n", card->irq);
2485 pci_release_regions(pdev); 2474 err = -ENODEV;
2486 pci_disable_device(pdev); 2475 goto irq_fail;
2487 iounmap(card->ctlmem);
2488 iounmap(card->mem);
2489 kfree(card);
2490 return -ENODEV;
2491 } 2476 }
2492 2477
2493 /* Record info we need */ 2478 /* Record info we need */
@@ -2513,13 +2498,8 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2513 while (i--) 2498 while (i--)
2514 free_netdev(card->ports[i].dev); 2499 free_netdev(card->ports[i].dev);
2515 pr_err("FarSync: out of memory\n"); 2500 pr_err("FarSync: out of memory\n");
2516 free_irq(card->irq, card); 2501 err = -ENOMEM;
2517 pci_release_regions(pdev); 2502 goto hdlcdev_fail;
2518 pci_disable_device(pdev);
2519 iounmap(card->ctlmem);
2520 iounmap(card->mem);
2521 kfree(card);
2522 return -ENODEV;
2523 } 2503 }
2524 card->ports[i].dev = dev; 2504 card->ports[i].dev = dev;
2525 card->ports[i].card = card; 2505 card->ports[i].card = card;
@@ -2565,9 +2545,16 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2565 pci_set_drvdata(pdev, card); 2545 pci_set_drvdata(pdev, card);
2566 2546
2567 /* Remainder of card setup */ 2547 /* Remainder of card setup */
2548 if (no_of_cards_added >= FST_MAX_CARDS) {
2549 pr_err("FarSync: too many cards\n");
2550 err = -ENOMEM;
2551 goto card_array_fail;
2552 }
2568 fst_card_array[no_of_cards_added] = card; 2553 fst_card_array[no_of_cards_added] = card;
2569 card->card_no = no_of_cards_added++; /* Record instance and bump it */ 2554 card->card_no = no_of_cards_added++; /* Record instance and bump it */
2570 fst_init_card(card); 2555 err = fst_init_card(card);
2556 if (err)
2557 goto init_card_fail;
2571 if (card->family == FST_FAMILY_TXU) { 2558 if (card->family == FST_FAMILY_TXU) {
2572 /* 2559 /*
2573 * Allocate a dma buffer for transmit and receives 2560 * Allocate a dma buffer for transmit and receives
@@ -2577,29 +2564,46 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2577 &card->rx_dma_handle_card); 2564 &card->rx_dma_handle_card);
2578 if (card->rx_dma_handle_host == NULL) { 2565 if (card->rx_dma_handle_host == NULL) {
2579 pr_err("Could not allocate rx dma buffer\n"); 2566 pr_err("Could not allocate rx dma buffer\n");
2580 fst_disable_intr(card); 2567 err = -ENOMEM;
2581 pci_release_regions(pdev); 2568 goto rx_dma_fail;
2582 pci_disable_device(pdev);
2583 iounmap(card->ctlmem);
2584 iounmap(card->mem);
2585 kfree(card);
2586 return -ENOMEM;
2587 } 2569 }
2588 card->tx_dma_handle_host = 2570 card->tx_dma_handle_host =
2589 pci_alloc_consistent(card->device, FST_MAX_MTU, 2571 pci_alloc_consistent(card->device, FST_MAX_MTU,
2590 &card->tx_dma_handle_card); 2572 &card->tx_dma_handle_card);
2591 if (card->tx_dma_handle_host == NULL) { 2573 if (card->tx_dma_handle_host == NULL) {
2592 pr_err("Could not allocate tx dma buffer\n"); 2574 pr_err("Could not allocate tx dma buffer\n");
2593 fst_disable_intr(card); 2575 err = -ENOMEM;
2594 pci_release_regions(pdev); 2576 goto tx_dma_fail;
2595 pci_disable_device(pdev);
2596 iounmap(card->ctlmem);
2597 iounmap(card->mem);
2598 kfree(card);
2599 return -ENOMEM;
2600 } 2577 }
2601 } 2578 }
2602 return 0; /* Success */ 2579 return 0; /* Success */
2580
2581tx_dma_fail:
2582 pci_free_consistent(card->device, FST_MAX_MTU,
2583 card->rx_dma_handle_host,
2584 card->rx_dma_handle_card);
2585rx_dma_fail:
2586 fst_disable_intr(card);
2587 for (i = 0 ; i < card->nports ; i++)
2588 unregister_hdlc_device(card->ports[i].dev);
2589init_card_fail:
2590 fst_card_array[card->card_no] = NULL;
2591card_array_fail:
2592 for (i = 0 ; i < card->nports ; i++)
2593 free_netdev(card->ports[i].dev);
2594hdlcdev_fail:
2595 free_irq(card->irq, card);
2596irq_fail:
2597 iounmap(card->ctlmem);
2598ioremap_ctlmem_fail:
2599 iounmap(card->mem);
2600ioremap_physmem_fail:
2601 pci_release_regions(pdev);
2602regions_fail:
2603 pci_disable_device(pdev);
2604enable_fail:
2605 kfree(card);
2606 return err;
2603} 2607}
2604 2608
2605/* 2609/*
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 82017f56e661..e6c56c5bb0f6 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -795,7 +795,11 @@ int ath10k_core_start(struct ath10k *ar)
795 if (status) 795 if (status)
796 goto err_htc_stop; 796 goto err_htc_stop;
797 797
798 ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1; 798 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features))
799 ar->free_vdev_map = (1 << TARGET_10X_NUM_VDEVS) - 1;
800 else
801 ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1;
802
799 INIT_LIST_HEAD(&ar->arvifs); 803 INIT_LIST_HEAD(&ar->arvifs);
800 804
801 if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags)) 805 if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags))
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 6c102b1312ff..eebc860c3655 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -312,7 +312,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
312 int msdu_len, msdu_chaining = 0; 312 int msdu_len, msdu_chaining = 0;
313 struct sk_buff *msdu; 313 struct sk_buff *msdu;
314 struct htt_rx_desc *rx_desc; 314 struct htt_rx_desc *rx_desc;
315 bool corrupted = false;
316 315
317 lockdep_assert_held(&htt->rx_ring.lock); 316 lockdep_assert_held(&htt->rx_ring.lock);
318 317
@@ -439,9 +438,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
439 last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) & 438 last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) &
440 RX_MSDU_END_INFO0_LAST_MSDU; 439 RX_MSDU_END_INFO0_LAST_MSDU;
441 440
442 if (msdu_chaining && !last_msdu)
443 corrupted = true;
444
445 if (last_msdu) { 441 if (last_msdu) {
446 msdu->next = NULL; 442 msdu->next = NULL;
447 break; 443 break;
@@ -457,20 +453,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
457 msdu_chaining = -1; 453 msdu_chaining = -1;
458 454
459 /* 455 /*
460 * Apparently FW sometimes reports weird chained MSDU sequences with
461 * more than one rx descriptor. This seems like a bug but needs more
462 * analyzing. For the time being fix it by dropping such sequences to
463 * avoid blowing up the host system.
464 */
465 if (corrupted) {
466 ath10k_warn("failed to pop chained msdus, dropping\n");
467 ath10k_htt_rx_free_msdu_chain(*head_msdu);
468 *head_msdu = NULL;
469 *tail_msdu = NULL;
470 msdu_chaining = -EINVAL;
471 }
472
473 /*
474 * Don't refill the ring yet. 456 * Don't refill the ring yet.
475 * 457 *
476 * First, the elements popped here are still in use - it is not 458 * First, the elements popped here are still in use - it is not
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index e3f67b8d3f80..40fd9b7b1426 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -36,7 +36,7 @@ config B43_SSB
36choice 36choice
37 prompt "Supported bus types" 37 prompt "Supported bus types"
38 depends on B43 38 depends on B43
39 default B43_BCMA_AND_SSB 39 default B43_BUSES_BCMA_AND_SSB
40 40
41config B43_BUSES_BCMA_AND_SSB 41config B43_BUSES_BCMA_AND_SSB
42 bool "BCMA and SSB" 42 bool "BCMA and SSB"
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 32538ac5f7e4..0d6a0bb1f876 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -5221,6 +5221,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
5221 /* We don't support 5 GHz on some PHYs yet */ 5221 /* We don't support 5 GHz on some PHYs yet */
5222 switch (dev->phy.type) { 5222 switch (dev->phy.type) {
5223 case B43_PHYTYPE_A: 5223 case B43_PHYTYPE_A:
5224 case B43_PHYTYPE_G:
5224 case B43_PHYTYPE_N: 5225 case B43_PHYTYPE_N:
5225 case B43_PHYTYPE_LP: 5226 case B43_PHYTYPE_LP:
5226 case B43_PHYTYPE_HT: 5227 case B43_PHYTYPE_HT:
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 4f38f19b8e3d..6e6ef3fc2247 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -811,9 +811,13 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
811 break; 811 break;
812 case B43_PHYTYPE_G: 812 case B43_PHYTYPE_G:
813 status.band = IEEE80211_BAND_2GHZ; 813 status.band = IEEE80211_BAND_2GHZ;
814 /* chanid is the radio channel cookie value as used 814 /* Somewhere between 478.104 and 508.1084 firmware for G-PHY
815 * to tune the radio. */ 815 * has been modified to be compatible with N-PHY and others.
816 status.freq = chanid + 2400; 816 */
817 if (dev->fw.rev >= 508)
818 status.freq = ieee80211_channel_to_frequency(chanid, status.band);
819 else
820 status.freq = chanid + 2400;
817 break; 821 break;
818 case B43_PHYTYPE_N: 822 case B43_PHYTYPE_N:
819 case B43_PHYTYPE_LP: 823 case B43_PHYTYPE_LP:
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index 6db51a666f61..d06fcb05adf2 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -1184,8 +1184,6 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo)
1184 bus->bus_priv.usb = bus_pub; 1184 bus->bus_priv.usb = bus_pub;
1185 dev_set_drvdata(dev, bus); 1185 dev_set_drvdata(dev, bus);
1186 bus->ops = &brcmf_usb_bus_ops; 1186 bus->ops = &brcmf_usb_bus_ops;
1187 bus->chip = bus_pub->devid;
1188 bus->chiprev = bus_pub->chiprev;
1189 bus->proto_type = BRCMF_PROTO_BCDC; 1187 bus->proto_type = BRCMF_PROTO_BCDC;
1190 bus->always_use_fws_queue = true; 1188 bus->always_use_fws_queue = true;
1191 1189
@@ -1194,6 +1192,9 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo)
1194 if (ret) 1192 if (ret)
1195 goto fail; 1193 goto fail;
1196 } 1194 }
1195 bus->chip = bus_pub->devid;
1196 bus->chiprev = bus_pub->chiprev;
1197
1197 /* request firmware here */ 1198 /* request firmware here */
1198 brcmf_fw_get_firmwares(dev, 0, brcmf_usb_get_fwname(devinfo), NULL, 1199 brcmf_fw_get_firmwares(dev, 0, brcmf_usb_get_fwname(devinfo), NULL,
1199 brcmf_usb_probe_phase2); 1200 brcmf_usb_probe_phase2);
diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c
index ed50de6362ed..6dc5dd3ced44 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rxon.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c
@@ -1068,13 +1068,6 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1068 /* recalculate basic rates */ 1068 /* recalculate basic rates */
1069 iwl_calc_basic_rates(priv, ctx); 1069 iwl_calc_basic_rates(priv, ctx);
1070 1070
1071 /*
1072 * force CTS-to-self frames protection if RTS-CTS is not preferred
1073 * one aggregation protection method
1074 */
1075 if (!priv->hw_params.use_rts_for_aggregation)
1076 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
1077
1078 if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || 1071 if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) ||
1079 !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK)) 1072 !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK))
1080 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; 1073 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
@@ -1480,11 +1473,6 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
1480 else 1473 else
1481 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 1474 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
1482 1475
1483 if (bss_conf->use_cts_prot)
1484 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
1485 else
1486 ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
1487
1488 memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); 1476 memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN);
1489 1477
1490 if (vif->type == NL80211_IFTYPE_AP || 1478 if (vif->type == NL80211_IFTYPE_AP ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h
index 0aa7c0085c9f..b1a33322b9ba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fw.h
@@ -88,6 +88,7 @@
88 * P2P client interfaces simultaneously if they are in different bindings. 88 * P2P client interfaces simultaneously if they are in different bindings.
89 * @IWL_UCODE_TLV_FLAGS_P2P_BSS_PS_SCM: support power save on BSS station and 89 * @IWL_UCODE_TLV_FLAGS_P2P_BSS_PS_SCM: support power save on BSS station and
90 * P2P client interfaces simultaneously if they are in same bindings. 90 * P2P client interfaces simultaneously if they are in same bindings.
91 * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD
91 * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save 92 * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save
92 * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering. 93 * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering.
93 * @IWL_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients 94 * @IWL_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c
index 8b5302777632..725ba49576bf 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c
@@ -667,10 +667,9 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
667 if (vif->bss_conf.qos) 667 if (vif->bss_conf.qos)
668 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA); 668 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA);
669 669
670 if (vif->bss_conf.use_cts_prot) { 670 if (vif->bss_conf.use_cts_prot)
671 cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT); 671 cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT);
672 cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_SELF_CTS_EN); 672
673 }
674 IWL_DEBUG_RATE(mvm, "use_cts_prot %d, ht_operation_mode %d\n", 673 IWL_DEBUG_RATE(mvm, "use_cts_prot %d, ht_operation_mode %d\n",
675 vif->bss_conf.use_cts_prot, 674 vif->bss_conf.use_cts_prot,
676 vif->bss_conf.ht_operation_mode); 675 vif->bss_conf.ht_operation_mode);
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 7215f5980186..9bfb90680cdc 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -303,6 +303,13 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
303 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; 303 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP;
304 } 304 }
305 305
306 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT &&
307 !iwlwifi_mod_params.uapsd_disable) {
308 hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD;
309 hw->uapsd_queues = IWL_UAPSD_AC_INFO;
310 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP;
311 }
312
306 hw->sta_data_size = sizeof(struct iwl_mvm_sta); 313 hw->sta_data_size = sizeof(struct iwl_mvm_sta);
307 hw->vif_data_size = sizeof(struct iwl_mvm_vif); 314 hw->vif_data_size = sizeof(struct iwl_mvm_vif);
308 hw->chanctx_data_size = sizeof(u16); 315 hw->chanctx_data_size = sizeof(u16);
@@ -1159,8 +1166,12 @@ static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac,
1159 1166
1160 bcast_mac = &cmd->macs[mvmvif->id]; 1167 bcast_mac = &cmd->macs[mvmvif->id];
1161 1168
1162 /* enable filtering only for associated stations */ 1169 /*
1163 if (vif->type != NL80211_IFTYPE_STATION || !vif->bss_conf.assoc) 1170 * enable filtering only for associated stations, but not for P2P
1171 * Clients
1172 */
1173 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p ||
1174 !vif->bss_conf.assoc)
1164 return; 1175 return;
1165 1176
1166 bcast_mac->default_discard = 1; 1177 bcast_mac->default_discard = 1;
@@ -1237,10 +1248,6 @@ static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm,
1237 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) 1248 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING))
1238 return 0; 1249 return 0;
1239 1250
1240 /* bcast filtering isn't supported for P2P client */
1241 if (vif->p2p)
1242 return 0;
1243
1244 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) 1251 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
1245 return 0; 1252 return 0;
1246 1253
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 4b6c7d4bd199..eac2b424f6a0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -588,9 +588,7 @@ static void iwl_build_scan_cmd(struct iwl_mvm *mvm,
588 struct iwl_scan_offload_cmd *scan, 588 struct iwl_scan_offload_cmd *scan,
589 struct iwl_mvm_scan_params *params) 589 struct iwl_mvm_scan_params *params)
590{ 590{
591 scan->channel_count = 591 scan->channel_count = req->n_channels;
592 mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels +
593 mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels;
594 scan->quiet_time = cpu_to_le16(IWL_ACTIVE_QUIET_TIME); 592 scan->quiet_time = cpu_to_le16(IWL_ACTIVE_QUIET_TIME);
595 scan->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); 593 scan->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH);
596 scan->good_CRC_th = IWL_GOOD_CRC_TH_DEFAULT; 594 scan->good_CRC_th = IWL_GOOD_CRC_TH_DEFAULT;
@@ -669,61 +667,37 @@ static void iwl_build_channel_cfg(struct iwl_mvm *mvm,
669 struct cfg80211_sched_scan_request *req, 667 struct cfg80211_sched_scan_request *req,
670 struct iwl_scan_channel_cfg *channels, 668 struct iwl_scan_channel_cfg *channels,
671 enum ieee80211_band band, 669 enum ieee80211_band band,
672 int *head, int *tail, 670 int *head,
673 u32 ssid_bitmap, 671 u32 ssid_bitmap,
674 struct iwl_mvm_scan_params *params) 672 struct iwl_mvm_scan_params *params)
675{ 673{
676 struct ieee80211_supported_band *s_band; 674 int i, index = 0;
677 int n_channels = req->n_channels;
678 int i, j, index = 0;
679 bool partial;
680 675
681 /* 676 for (i = 0; i < req->n_channels; i++) {
682 * We have to configure all supported channels, even if we don't want to 677 struct ieee80211_channel *chan = req->channels[i];
683 * scan on them, but we have to send channels in the order that we want 678
684 * to scan. So add requested channels to head of the list and others to 679 if (chan->band != band)
685 * the end. 680 continue;
686 */ 681
687 s_band = &mvm->nvm_data->bands[band]; 682 index = *head;
688 683 (*head)++;
689 for (i = 0; i < s_band->n_channels && *head <= *tail; i++) { 684
690 partial = false; 685 channels->channel_number[index] = cpu_to_le16(chan->hw_value);
691 for (j = 0; j < n_channels; j++)
692 if (s_band->channels[i].center_freq ==
693 req->channels[j]->center_freq) {
694 index = *head;
695 (*head)++;
696 /*
697 * Channels that came with the request will be
698 * in partial scan .
699 */
700 partial = true;
701 break;
702 }
703 if (!partial) {
704 index = *tail;
705 (*tail)--;
706 }
707 channels->channel_number[index] =
708 cpu_to_le16(ieee80211_frequency_to_channel(
709 s_band->channels[i].center_freq));
710 channels->dwell_time[index][0] = params->dwell[band].active; 686 channels->dwell_time[index][0] = params->dwell[band].active;
711 channels->dwell_time[index][1] = params->dwell[band].passive; 687 channels->dwell_time[index][1] = params->dwell[band].passive;
712 688
713 channels->iter_count[index] = cpu_to_le16(1); 689 channels->iter_count[index] = cpu_to_le16(1);
714 channels->iter_interval[index] = 0; 690 channels->iter_interval[index] = 0;
715 691
716 if (!(s_band->channels[i].flags & IEEE80211_CHAN_NO_IR)) 692 if (!(chan->flags & IEEE80211_CHAN_NO_IR))
717 channels->type[index] |= 693 channels->type[index] |=
718 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE); 694 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE);
719 695
720 channels->type[index] |= 696 channels->type[index] |=
721 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_FULL); 697 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_FULL |
722 if (partial) 698 IWL_SCAN_OFFLOAD_CHANNEL_PARTIAL);
723 channels->type[index] |=
724 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_PARTIAL);
725 699
726 if (s_band->channels[i].flags & IEEE80211_CHAN_NO_HT40) 700 if (chan->flags & IEEE80211_CHAN_NO_HT40)
727 channels->type[index] |= 701 channels->type[index] |=
728 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_NARROW); 702 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_NARROW);
729 703
@@ -740,7 +714,6 @@ int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm,
740 int band_2ghz = mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels; 714 int band_2ghz = mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels;
741 int band_5ghz = mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; 715 int band_5ghz = mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels;
742 int head = 0; 716 int head = 0;
743 int tail = band_2ghz + band_5ghz - 1;
744 u32 ssid_bitmap; 717 u32 ssid_bitmap;
745 int cmd_len; 718 int cmd_len;
746 int ret; 719 int ret;
@@ -772,7 +745,7 @@ int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm,
772 &scan_cfg->scan_cmd.tx_cmd[0], 745 &scan_cfg->scan_cmd.tx_cmd[0],
773 scan_cfg->data); 746 scan_cfg->data);
774 iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg, 747 iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg,
775 IEEE80211_BAND_2GHZ, &head, &tail, 748 IEEE80211_BAND_2GHZ, &head,
776 ssid_bitmap, &params); 749 ssid_bitmap, &params);
777 } 750 }
778 if (band_5ghz) { 751 if (band_5ghz) {
@@ -782,7 +755,7 @@ int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm,
782 scan_cfg->data + 755 scan_cfg->data +
783 SCAN_OFFLOAD_PROBE_REQ_SIZE); 756 SCAN_OFFLOAD_PROBE_REQ_SIZE);
784 iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg, 757 iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg,
785 IEEE80211_BAND_5GHZ, &head, &tail, 758 IEEE80211_BAND_5GHZ, &head,
786 ssid_bitmap, &params); 759 ssid_bitmap, &params);
787 } 760 }
788 761
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 7091a18d5a72..98950e45c7b0 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -367,6 +367,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
367 {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)}, 367 {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)},
368 {IWL_PCI_DEVICE(0x095A, 0x5412, iwl7265_2ac_cfg)}, 368 {IWL_PCI_DEVICE(0x095A, 0x5412, iwl7265_2ac_cfg)},
369 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)}, 369 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x095A, 0x5510, iwl7265_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)}, 371 {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)},
371 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)}, 372 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)},
372 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)}, 373 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)},
@@ -380,7 +381,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
380 {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)}, 381 {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)},
381 {IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)}, 382 {IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)},
382 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)}, 383 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)},
383 {IWL_PCI_DEVICE(0x095A, 0x9200, iwl7265_2ac_cfg)}, 384 {IWL_PCI_DEVICE(0x095B, 0x9200, iwl7265_2ac_cfg)},
384 {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)}, 385 {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)},
385 {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)}, 386 {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)},
386 {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)}, 387 {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)},
diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
index 5b32106182f8..fe0f66f73507 100644
--- a/drivers/net/wireless/mwifiex/11n_aggr.c
+++ b/drivers/net/wireless/mwifiex/11n_aggr.c
@@ -185,6 +185,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
185 skb_reserve(skb_aggr, headroom + sizeof(struct txpd)); 185 skb_reserve(skb_aggr, headroom + sizeof(struct txpd));
186 tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr); 186 tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr);
187 187
188 memset(tx_info_aggr, 0, sizeof(*tx_info_aggr));
188 tx_info_aggr->bss_type = tx_info_src->bss_type; 189 tx_info_aggr->bss_type = tx_info_src->bss_type;
189 tx_info_aggr->bss_num = tx_info_src->bss_num; 190 tx_info_aggr->bss_num = tx_info_src->bss_num;
190 191
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index e95dec91a561..b511613bba2d 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -220,6 +220,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
220 } 220 }
221 221
222 tx_info = MWIFIEX_SKB_TXCB(skb); 222 tx_info = MWIFIEX_SKB_TXCB(skb);
223 memset(tx_info, 0, sizeof(*tx_info));
223 tx_info->bss_num = priv->bss_num; 224 tx_info->bss_num = priv->bss_num;
224 tx_info->bss_type = priv->bss_type; 225 tx_info->bss_type = priv->bss_type;
225 tx_info->pkt_len = pkt_len; 226 tx_info->pkt_len = pkt_len;
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index 8dee6c86f4f1..c161141f6c39 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -453,6 +453,7 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter)
453 453
454 if (skb) { 454 if (skb) {
455 rx_info = MWIFIEX_SKB_RXCB(skb); 455 rx_info = MWIFIEX_SKB_RXCB(skb);
456 memset(rx_info, 0, sizeof(*rx_info));
456 rx_info->bss_num = priv->bss_num; 457 rx_info->bss_num = priv->bss_num;
457 rx_info->bss_type = priv->bss_type; 458 rx_info->bss_type = priv->bss_type;
458 } 459 }
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index cbabc12fbda3..e91cd0fa5ca8 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -645,6 +645,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
645 } 645 }
646 646
647 tx_info = MWIFIEX_SKB_TXCB(skb); 647 tx_info = MWIFIEX_SKB_TXCB(skb);
648 memset(tx_info, 0, sizeof(*tx_info));
648 tx_info->bss_num = priv->bss_num; 649 tx_info->bss_num = priv->bss_num;
649 tx_info->bss_type = priv->bss_type; 650 tx_info->bss_type = priv->bss_type;
650 tx_info->pkt_len = skb->len; 651 tx_info->pkt_len = skb->len;
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 574d4b597468..2cc9b6fca490 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -50,7 +50,7 @@ mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb,
50 return -1; 50 return -1;
51 } 51 }
52 mapping.len = size; 52 mapping.len = size;
53 memcpy(skb->cb, &mapping, sizeof(mapping)); 53 mwifiex_store_mapping(skb, &mapping);
54 return 0; 54 return 0;
55} 55}
56 56
@@ -60,7 +60,7 @@ static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter,
60 struct pcie_service_card *card = adapter->card; 60 struct pcie_service_card *card = adapter->card;
61 struct mwifiex_dma_mapping mapping; 61 struct mwifiex_dma_mapping mapping;
62 62
63 MWIFIEX_SKB_PACB(skb, &mapping); 63 mwifiex_get_mapping(skb, &mapping);
64 pci_unmap_single(card->dev, mapping.addr, mapping.len, flags); 64 pci_unmap_single(card->dev, mapping.addr, mapping.len, flags);
65} 65}
66 66
diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c
index 5fce7e78a36e..70eb863c7249 100644
--- a/drivers/net/wireless/mwifiex/sta_tx.c
+++ b/drivers/net/wireless/mwifiex/sta_tx.c
@@ -150,6 +150,7 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags)
150 return -1; 150 return -1;
151 151
152 tx_info = MWIFIEX_SKB_TXCB(skb); 152 tx_info = MWIFIEX_SKB_TXCB(skb);
153 memset(tx_info, 0, sizeof(*tx_info));
153 tx_info->bss_num = priv->bss_num; 154 tx_info->bss_num = priv->bss_num;
154 tx_info->bss_type = priv->bss_type; 155 tx_info->bss_type = priv->bss_type;
155 tx_info->pkt_len = data_len - (sizeof(struct txpd) + INTF_HEADER_LEN); 156 tx_info->pkt_len = data_len - (sizeof(struct txpd) + INTF_HEADER_LEN);
diff --git a/drivers/net/wireless/mwifiex/tdls.c b/drivers/net/wireless/mwifiex/tdls.c
index e73034fbbde9..0e88364e0c67 100644
--- a/drivers/net/wireless/mwifiex/tdls.c
+++ b/drivers/net/wireless/mwifiex/tdls.c
@@ -605,6 +605,7 @@ int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
605 } 605 }
606 606
607 tx_info = MWIFIEX_SKB_TXCB(skb); 607 tx_info = MWIFIEX_SKB_TXCB(skb);
608 memset(tx_info, 0, sizeof(*tx_info));
608 tx_info->bss_num = priv->bss_num; 609 tx_info->bss_num = priv->bss_num;
609 tx_info->bss_type = priv->bss_type; 610 tx_info->bss_type = priv->bss_type;
610 611
@@ -760,6 +761,7 @@ int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
760 skb->priority = MWIFIEX_PRIO_VI; 761 skb->priority = MWIFIEX_PRIO_VI;
761 762
762 tx_info = MWIFIEX_SKB_TXCB(skb); 763 tx_info = MWIFIEX_SKB_TXCB(skb);
764 memset(tx_info, 0, sizeof(*tx_info));
763 tx_info->bss_num = priv->bss_num; 765 tx_info->bss_num = priv->bss_num;
764 tx_info->bss_type = priv->bss_type; 766 tx_info->bss_type = priv->bss_type;
765 tx_info->flags |= MWIFIEX_BUF_FLAG_TDLS_PKT; 767 tx_info->flags |= MWIFIEX_BUF_FLAG_TDLS_PKT;
diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c
index 37f26afd4314..fd7e5b9b4581 100644
--- a/drivers/net/wireless/mwifiex/txrx.c
+++ b/drivers/net/wireless/mwifiex/txrx.c
@@ -55,6 +55,7 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
55 return -1; 55 return -1;
56 } 56 }
57 57
58 memset(rx_info, 0, sizeof(*rx_info));
58 rx_info->bss_num = priv->bss_num; 59 rx_info->bss_num = priv->bss_num;
59 rx_info->bss_type = priv->bss_type; 60 rx_info->bss_type = priv->bss_type;
60 61
diff --git a/drivers/net/wireless/mwifiex/uap_txrx.c b/drivers/net/wireless/mwifiex/uap_txrx.c
index 9a56bc61cb1d..b0601b91cc4f 100644
--- a/drivers/net/wireless/mwifiex/uap_txrx.c
+++ b/drivers/net/wireless/mwifiex/uap_txrx.c
@@ -175,6 +175,7 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
175 } 175 }
176 176
177 tx_info = MWIFIEX_SKB_TXCB(skb); 177 tx_info = MWIFIEX_SKB_TXCB(skb);
178 memset(tx_info, 0, sizeof(*tx_info));
178 tx_info->bss_num = priv->bss_num; 179 tx_info->bss_num = priv->bss_num;
179 tx_info->bss_type = priv->bss_type; 180 tx_info->bss_type = priv->bss_type;
180 tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT; 181 tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT;
diff --git a/drivers/net/wireless/mwifiex/util.h b/drivers/net/wireless/mwifiex/util.h
index ddae57021397..caadb3737b9e 100644
--- a/drivers/net/wireless/mwifiex/util.h
+++ b/drivers/net/wireless/mwifiex/util.h
@@ -20,32 +20,55 @@
20#ifndef _MWIFIEX_UTIL_H_ 20#ifndef _MWIFIEX_UTIL_H_
21#define _MWIFIEX_UTIL_H_ 21#define _MWIFIEX_UTIL_H_
22 22
23struct mwifiex_dma_mapping {
24 dma_addr_t addr;
25 size_t len;
26};
27
28struct mwifiex_cb {
29 struct mwifiex_dma_mapping dma_mapping;
30 union {
31 struct mwifiex_rxinfo rx_info;
32 struct mwifiex_txinfo tx_info;
33 };
34};
35
23static inline struct mwifiex_rxinfo *MWIFIEX_SKB_RXCB(struct sk_buff *skb) 36static inline struct mwifiex_rxinfo *MWIFIEX_SKB_RXCB(struct sk_buff *skb)
24{ 37{
25 return (struct mwifiex_rxinfo *)(skb->cb + sizeof(dma_addr_t)); 38 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
39
40 BUILD_BUG_ON(sizeof(struct mwifiex_cb) > sizeof(skb->cb));
41 return &cb->rx_info;
26} 42}
27 43
28static inline struct mwifiex_txinfo *MWIFIEX_SKB_TXCB(struct sk_buff *skb) 44static inline struct mwifiex_txinfo *MWIFIEX_SKB_TXCB(struct sk_buff *skb)
29{ 45{
30 return (struct mwifiex_txinfo *)(skb->cb + sizeof(dma_addr_t)); 46 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
47
48 return &cb->tx_info;
31} 49}
32 50
33struct mwifiex_dma_mapping { 51static inline void mwifiex_store_mapping(struct sk_buff *skb,
34 dma_addr_t addr; 52 struct mwifiex_dma_mapping *mapping)
35 size_t len; 53{
36}; 54 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
55
56 memcpy(&cb->dma_mapping, mapping, sizeof(*mapping));
57}
37 58
38static inline void MWIFIEX_SKB_PACB(struct sk_buff *skb, 59static inline void mwifiex_get_mapping(struct sk_buff *skb,
39 struct mwifiex_dma_mapping *mapping) 60 struct mwifiex_dma_mapping *mapping)
40{ 61{
41 memcpy(mapping, skb->cb, sizeof(*mapping)); 62 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
63
64 memcpy(mapping, &cb->dma_mapping, sizeof(*mapping));
42} 65}
43 66
44static inline dma_addr_t MWIFIEX_SKB_DMA_ADDR(struct sk_buff *skb) 67static inline dma_addr_t MWIFIEX_SKB_DMA_ADDR(struct sk_buff *skb)
45{ 68{
46 struct mwifiex_dma_mapping mapping; 69 struct mwifiex_dma_mapping mapping;
47 70
48 MWIFIEX_SKB_PACB(skb, &mapping); 71 mwifiex_get_mapping(skb, &mapping);
49 72
50 return mapping.addr; 73 return mapping.addr;
51} 74}
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 2f1cd929c6f6..a511cccc9f01 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1681,8 +1681,13 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1681 /* 1681 /*
1682 * Detect if this device has an hardware controlled radio. 1682 * Detect if this device has an hardware controlled radio.
1683 */ 1683 */
1684 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) 1684 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) {
1685 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags); 1685 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags);
1686 /*
1687 * On this device RFKILL initialized during probe does not work.
1688 */
1689 __set_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags);
1690 }
1686 1691
1687 /* 1692 /*
1688 * Check if the BBP tuning should be enabled. 1693 * Check if the BBP tuning should be enabled.
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index a49c3d73ea2c..832006b5aab1 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -229,6 +229,31 @@ static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *timer)
229/* 229/*
230 * Firmware functions 230 * Firmware functions
231 */ 231 */
232static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev)
233{
234 __le32 *reg;
235 u32 fw_mode;
236
237 reg = kmalloc(sizeof(*reg), GFP_KERNEL);
238 if (reg == NULL)
239 return -ENOMEM;
240 /* cannot use rt2x00usb_register_read here as it uses different
241 * mode (MULTI_READ vs. DEVICE_MODE) and does not pass the
242 * magic value USB_MODE_AUTORUN (0x11) to the device, thus the
243 * returned value would be invalid.
244 */
245 rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
246 USB_VENDOR_REQUEST_IN, 0, USB_MODE_AUTORUN,
247 reg, sizeof(*reg), REGISTER_TIMEOUT_FIRMWARE);
248 fw_mode = le32_to_cpu(*reg);
249 kfree(reg);
250
251 if ((fw_mode & 0x00000003) == 2)
252 return 1;
253
254 return 0;
255}
256
232static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) 257static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
233{ 258{
234 return FIRMWARE_RT2870; 259 return FIRMWARE_RT2870;
@@ -240,6 +265,7 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
240 int status; 265 int status;
241 u32 offset; 266 u32 offset;
242 u32 length; 267 u32 length;
268 int retval;
243 269
244 /* 270 /*
245 * Check which section of the firmware we need. 271 * Check which section of the firmware we need.
@@ -257,8 +283,16 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
257 /* 283 /*
258 * Write firmware to device. 284 * Write firmware to device.
259 */ 285 */
260 rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE, 286 retval = rt2800usb_autorun_detect(rt2x00dev);
261 data + offset, length); 287 if (retval < 0)
288 return retval;
289 if (retval) {
290 rt2x00_info(rt2x00dev,
291 "Firmware loading not required - NIC in AutoRun mode\n");
292 } else {
293 rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
294 data + offset, length);
295 }
262 296
263 rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0); 297 rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
264 rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0); 298 rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
@@ -735,11 +769,26 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
735/* 769/*
736 * Device probe functions. 770 * Device probe functions.
737 */ 771 */
772static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev)
773{
774 int retval;
775
776 retval = rt2800usb_autorun_detect(rt2x00dev);
777 if (retval < 0)
778 return retval;
779 if (retval)
780 return 1;
781 return rt2800_efuse_detect(rt2x00dev);
782}
783
738static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev) 784static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev)
739{ 785{
740 int retval; 786 int retval;
741 787
742 if (rt2800_efuse_detect(rt2x00dev)) 788 retval = rt2800usb_efuse_detect(rt2x00dev);
789 if (retval < 0)
790 return retval;
791 if (retval)
743 retval = rt2800_read_eeprom_efuse(rt2x00dev); 792 retval = rt2800_read_eeprom_efuse(rt2x00dev);
744 else 793 else
745 retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, 794 retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 010b76505243..d13f25cd70d5 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -693,6 +693,7 @@ enum rt2x00_capability_flags {
693 REQUIRE_SW_SEQNO, 693 REQUIRE_SW_SEQNO,
694 REQUIRE_HT_TX_DESC, 694 REQUIRE_HT_TX_DESC,
695 REQUIRE_PS_AUTOWAKE, 695 REQUIRE_PS_AUTOWAKE,
696 REQUIRE_DELAYED_RFKILL,
696 697
697 /* 698 /*
698 * Capabilities 699 * Capabilities
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 2bde6729f5e6..4fa43a2eeb73 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1126,9 +1126,10 @@ static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
1126 return; 1126 return;
1127 1127
1128 /* 1128 /*
1129 * Unregister extra components. 1129 * Stop rfkill polling.
1130 */ 1130 */
1131 rt2x00rfkill_unregister(rt2x00dev); 1131 if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1132 rt2x00rfkill_unregister(rt2x00dev);
1132 1133
1133 /* 1134 /*
1134 * Allow the HW to uninitialize. 1135 * Allow the HW to uninitialize.
@@ -1166,6 +1167,12 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1166 1167
1167 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags); 1168 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
1168 1169
1170 /*
1171 * Start rfkill polling.
1172 */
1173 if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1174 rt2x00rfkill_register(rt2x00dev);
1175
1169 return 0; 1176 return 0;
1170} 1177}
1171 1178
@@ -1375,7 +1382,12 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1375 rt2x00link_register(rt2x00dev); 1382 rt2x00link_register(rt2x00dev);
1376 rt2x00leds_register(rt2x00dev); 1383 rt2x00leds_register(rt2x00dev);
1377 rt2x00debug_register(rt2x00dev); 1384 rt2x00debug_register(rt2x00dev);
1378 rt2x00rfkill_register(rt2x00dev); 1385
1386 /*
1387 * Start rfkill polling.
1388 */
1389 if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1390 rt2x00rfkill_register(rt2x00dev);
1379 1391
1380 return 0; 1392 return 0;
1381 1393
@@ -1391,6 +1403,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1391 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); 1403 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
1392 1404
1393 /* 1405 /*
1406 * Stop rfkill polling.
1407 */
1408 if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1409 rt2x00rfkill_unregister(rt2x00dev);
1410
1411 /*
1394 * Disable radio. 1412 * Disable radio.
1395 */ 1413 */
1396 rt2x00lib_disable_radio(rt2x00dev); 1414 rt2x00lib_disable_radio(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 212ac4842c16..004dff9b962d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -487,6 +487,8 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
487 crypto.cipher = rt2x00crypto_key_to_cipher(key); 487 crypto.cipher = rt2x00crypto_key_to_cipher(key);
488 if (crypto.cipher == CIPHER_NONE) 488 if (crypto.cipher == CIPHER_NONE)
489 return -EOPNOTSUPP; 489 return -EOPNOTSUPP;
490 if (crypto.cipher == CIPHER_TKIP && rt2x00_is_usb(rt2x00dev))
491 return -EOPNOTSUPP;
490 492
491 crypto.cmd = cmd; 493 crypto.cmd = cmd;
492 494
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index e7bcf62347d5..831b65f93feb 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -93,6 +93,7 @@ enum rt2x00usb_mode_offset {
93 USB_MODE_SLEEP = 7, /* RT73USB */ 93 USB_MODE_SLEEP = 7, /* RT73USB */
94 USB_MODE_FIRMWARE = 8, /* RT73USB */ 94 USB_MODE_FIRMWARE = 8, /* RT73USB */
95 USB_MODE_WAKEUP = 9, /* RT73USB */ 95 USB_MODE_WAKEUP = 9, /* RT73USB */
96 USB_MODE_AUTORUN = 17, /* RT2800USB */
96}; 97};
97 98
98/** 99/**
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index 4dd7c4a1923b..2532ce85d718 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -222,6 +222,7 @@ struct xenvif {
222 222
223 /* Queues */ 223 /* Queues */
224 struct xenvif_queue *queues; 224 struct xenvif_queue *queues;
225 unsigned int num_queues; /* active queues, resource allocated */
225 226
226 /* Miscellaneous private stuff. */ 227 /* Miscellaneous private stuff. */
227 struct net_device *dev; 228 struct net_device *dev;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 852da34b8961..9e97c7ca0ddd 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -137,32 +137,11 @@ static void xenvif_wake_queue_callback(unsigned long data)
137 } 137 }
138} 138}
139 139
140static u16 xenvif_select_queue(struct net_device *dev, struct sk_buff *skb,
141 void *accel_priv, select_queue_fallback_t fallback)
142{
143 unsigned int num_queues = dev->real_num_tx_queues;
144 u32 hash;
145 u16 queue_index;
146
147 /* First, check if there is only one queue to optimise the
148 * single-queue or old frontend scenario.
149 */
150 if (num_queues == 1) {
151 queue_index = 0;
152 } else {
153 /* Use skb_get_hash to obtain an L4 hash if available */
154 hash = skb_get_hash(skb);
155 queue_index = hash % num_queues;
156 }
157
158 return queue_index;
159}
160
161static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) 140static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
162{ 141{
163 struct xenvif *vif = netdev_priv(dev); 142 struct xenvif *vif = netdev_priv(dev);
164 struct xenvif_queue *queue = NULL; 143 struct xenvif_queue *queue = NULL;
165 unsigned int num_queues = dev->real_num_tx_queues; 144 unsigned int num_queues = vif->num_queues;
166 u16 index; 145 u16 index;
167 int min_slots_needed; 146 int min_slots_needed;
168 147
@@ -225,7 +204,7 @@ static struct net_device_stats *xenvif_get_stats(struct net_device *dev)
225{ 204{
226 struct xenvif *vif = netdev_priv(dev); 205 struct xenvif *vif = netdev_priv(dev);
227 struct xenvif_queue *queue = NULL; 206 struct xenvif_queue *queue = NULL;
228 unsigned int num_queues = dev->real_num_tx_queues; 207 unsigned int num_queues = vif->num_queues;
229 unsigned long rx_bytes = 0; 208 unsigned long rx_bytes = 0;
230 unsigned long rx_packets = 0; 209 unsigned long rx_packets = 0;
231 unsigned long tx_bytes = 0; 210 unsigned long tx_bytes = 0;
@@ -256,7 +235,7 @@ out:
256static void xenvif_up(struct xenvif *vif) 235static void xenvif_up(struct xenvif *vif)
257{ 236{
258 struct xenvif_queue *queue = NULL; 237 struct xenvif_queue *queue = NULL;
259 unsigned int num_queues = vif->dev->real_num_tx_queues; 238 unsigned int num_queues = vif->num_queues;
260 unsigned int queue_index; 239 unsigned int queue_index;
261 240
262 for (queue_index = 0; queue_index < num_queues; ++queue_index) { 241 for (queue_index = 0; queue_index < num_queues; ++queue_index) {
@@ -272,7 +251,7 @@ static void xenvif_up(struct xenvif *vif)
272static void xenvif_down(struct xenvif *vif) 251static void xenvif_down(struct xenvif *vif)
273{ 252{
274 struct xenvif_queue *queue = NULL; 253 struct xenvif_queue *queue = NULL;
275 unsigned int num_queues = vif->dev->real_num_tx_queues; 254 unsigned int num_queues = vif->num_queues;
276 unsigned int queue_index; 255 unsigned int queue_index;
277 256
278 for (queue_index = 0; queue_index < num_queues; ++queue_index) { 257 for (queue_index = 0; queue_index < num_queues; ++queue_index) {
@@ -379,7 +358,7 @@ static void xenvif_get_ethtool_stats(struct net_device *dev,
379 struct ethtool_stats *stats, u64 * data) 358 struct ethtool_stats *stats, u64 * data)
380{ 359{
381 struct xenvif *vif = netdev_priv(dev); 360 struct xenvif *vif = netdev_priv(dev);
382 unsigned int num_queues = dev->real_num_tx_queues; 361 unsigned int num_queues = vif->num_queues;
383 int i; 362 int i;
384 unsigned int queue_index; 363 unsigned int queue_index;
385 struct xenvif_stats *vif_stats; 364 struct xenvif_stats *vif_stats;
@@ -424,7 +403,6 @@ static const struct net_device_ops xenvif_netdev_ops = {
424 .ndo_fix_features = xenvif_fix_features, 403 .ndo_fix_features = xenvif_fix_features,
425 .ndo_set_mac_address = eth_mac_addr, 404 .ndo_set_mac_address = eth_mac_addr,
426 .ndo_validate_addr = eth_validate_addr, 405 .ndo_validate_addr = eth_validate_addr,
427 .ndo_select_queue = xenvif_select_queue,
428}; 406};
429 407
430struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, 408struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
@@ -438,7 +416,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
438 snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle); 416 snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
439 /* Allocate a netdev with the max. supported number of queues. 417 /* Allocate a netdev with the max. supported number of queues.
440 * When the guest selects the desired number, it will be updated 418 * When the guest selects the desired number, it will be updated
441 * via netif_set_real_num_tx_queues(). 419 * via netif_set_real_num_*_queues().
442 */ 420 */
443 dev = alloc_netdev_mq(sizeof(struct xenvif), name, ether_setup, 421 dev = alloc_netdev_mq(sizeof(struct xenvif), name, ether_setup,
444 xenvif_max_queues); 422 xenvif_max_queues);
@@ -458,11 +436,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
458 vif->dev = dev; 436 vif->dev = dev;
459 vif->disabled = false; 437 vif->disabled = false;
460 438
461 /* Start out with no queues. The call below does not require 439 /* Start out with no queues. */
462 * rtnl_lock() as it happens before register_netdev().
463 */
464 vif->queues = NULL; 440 vif->queues = NULL;
465 netif_set_real_num_tx_queues(dev, 0); 441 vif->num_queues = 0;
466 442
467 dev->netdev_ops = &xenvif_netdev_ops; 443 dev->netdev_ops = &xenvif_netdev_ops;
468 dev->hw_features = NETIF_F_SG | 444 dev->hw_features = NETIF_F_SG |
@@ -677,7 +653,7 @@ static void xenvif_wait_unmap_timeout(struct xenvif_queue *queue,
677void xenvif_disconnect(struct xenvif *vif) 653void xenvif_disconnect(struct xenvif *vif)
678{ 654{
679 struct xenvif_queue *queue = NULL; 655 struct xenvif_queue *queue = NULL;
680 unsigned int num_queues = vif->dev->real_num_tx_queues; 656 unsigned int num_queues = vif->num_queues;
681 unsigned int queue_index; 657 unsigned int queue_index;
682 658
683 if (netif_carrier_ok(vif->dev)) 659 if (netif_carrier_ok(vif->dev))
@@ -724,7 +700,7 @@ void xenvif_deinit_queue(struct xenvif_queue *queue)
724void xenvif_free(struct xenvif *vif) 700void xenvif_free(struct xenvif *vif)
725{ 701{
726 struct xenvif_queue *queue = NULL; 702 struct xenvif_queue *queue = NULL;
727 unsigned int num_queues = vif->dev->real_num_tx_queues; 703 unsigned int num_queues = vif->num_queues;
728 unsigned int queue_index; 704 unsigned int queue_index;
729 /* Here we want to avoid timeout messages if an skb can be legitimately 705 /* Here we want to avoid timeout messages if an skb can be legitimately
730 * stuck somewhere else. Realistically this could be an another vif's 706 * stuck somewhere else. Realistically this could be an another vif's
@@ -748,12 +724,9 @@ void xenvif_free(struct xenvif *vif)
748 xenvif_deinit_queue(queue); 724 xenvif_deinit_queue(queue);
749 } 725 }
750 726
751 /* Free the array of queues. The call below does not require
752 * rtnl_lock() because it happens after unregister_netdev().
753 */
754 netif_set_real_num_tx_queues(vif->dev, 0);
755 vfree(vif->queues); 727 vfree(vif->queues);
756 vif->queues = NULL; 728 vif->queues = NULL;
729 vif->num_queues = 0;
757 730
758 free_netdev(vif->dev); 731 free_netdev(vif->dev);
759 732
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 96c63dc2509e..3d85acd84bad 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -527,9 +527,7 @@ static void connect(struct backend_info *be)
527 /* Use the number of queues requested by the frontend */ 527 /* Use the number of queues requested by the frontend */
528 be->vif->queues = vzalloc(requested_num_queues * 528 be->vif->queues = vzalloc(requested_num_queues *
529 sizeof(struct xenvif_queue)); 529 sizeof(struct xenvif_queue));
530 rtnl_lock(); 530 be->vif->num_queues = requested_num_queues;
531 netif_set_real_num_tx_queues(be->vif->dev, requested_num_queues);
532 rtnl_unlock();
533 531
534 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) { 532 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) {
535 queue = &be->vif->queues[queue_index]; 533 queue = &be->vif->queues[queue_index];
@@ -546,9 +544,7 @@ static void connect(struct backend_info *be)
546 * earlier queues can be destroyed using the regular 544 * earlier queues can be destroyed using the regular
547 * disconnect logic. 545 * disconnect logic.
548 */ 546 */
549 rtnl_lock(); 547 be->vif->num_queues = queue_index;
550 netif_set_real_num_tx_queues(be->vif->dev, queue_index);
551 rtnl_unlock();
552 goto err; 548 goto err;
553 } 549 }
554 550
@@ -561,13 +557,19 @@ static void connect(struct backend_info *be)
561 * and also clean up any previously initialised queues. 557 * and also clean up any previously initialised queues.
562 */ 558 */
563 xenvif_deinit_queue(queue); 559 xenvif_deinit_queue(queue);
564 rtnl_lock(); 560 be->vif->num_queues = queue_index;
565 netif_set_real_num_tx_queues(be->vif->dev, queue_index);
566 rtnl_unlock();
567 goto err; 561 goto err;
568 } 562 }
569 } 563 }
570 564
565 /* Initialisation completed, tell core driver the number of
566 * active queues.
567 */
568 rtnl_lock();
569 netif_set_real_num_tx_queues(be->vif->dev, requested_num_queues);
570 netif_set_real_num_rx_queues(be->vif->dev, requested_num_queues);
571 rtnl_unlock();
572
571 xenvif_carrier_on(be->vif); 573 xenvif_carrier_on(be->vif);
572 574
573 unregister_hotplug_status_watch(be); 575 unregister_hotplug_status_watch(be);
@@ -582,13 +584,11 @@ static void connect(struct backend_info *be)
582 return; 584 return;
583 585
584err: 586err:
585 if (be->vif->dev->real_num_tx_queues > 0) 587 if (be->vif->num_queues > 0)
586 xenvif_disconnect(be->vif); /* Clean up existing queues */ 588 xenvif_disconnect(be->vif); /* Clean up existing queues */
587 vfree(be->vif->queues); 589 vfree(be->vif->queues);
588 be->vif->queues = NULL; 590 be->vif->queues = NULL;
589 rtnl_lock(); 591 be->vif->num_queues = 0;
590 netif_set_real_num_tx_queues(be->vif->dev, 0);
591 rtnl_unlock();
592 return; 592 return;
593} 593}
594 594
@@ -596,7 +596,7 @@ err:
596static int connect_rings(struct backend_info *be, struct xenvif_queue *queue) 596static int connect_rings(struct backend_info *be, struct xenvif_queue *queue)
597{ 597{
598 struct xenbus_device *dev = be->dev; 598 struct xenbus_device *dev = be->dev;
599 unsigned int num_queues = queue->vif->dev->real_num_tx_queues; 599 unsigned int num_queues = queue->vif->num_queues;
600 unsigned long tx_ring_ref, rx_ring_ref; 600 unsigned long tx_ring_ref, rx_ring_ref;
601 unsigned int tx_evtchn, rx_evtchn; 601 unsigned int tx_evtchn, rx_evtchn;
602 int err; 602 int err;
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 5a7872ac3566..055222bae6e4 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1287,7 +1287,7 @@ static irqreturn_t xennet_rx_interrupt(int irq, void *dev_id)
1287 1287
1288 if (likely(netif_carrier_ok(dev) && 1288 if (likely(netif_carrier_ok(dev) &&
1289 RING_HAS_UNCONSUMED_RESPONSES(&queue->rx))) 1289 RING_HAS_UNCONSUMED_RESPONSES(&queue->rx)))
1290 napi_schedule(&queue->napi); 1290 napi_schedule(&queue->napi);
1291 1291
1292 return IRQ_HANDLED; 1292 return IRQ_HANDLED;
1293} 1293}
@@ -1437,16 +1437,12 @@ static void xennet_end_access(int ref, void *page)
1437static void xennet_disconnect_backend(struct netfront_info *info) 1437static void xennet_disconnect_backend(struct netfront_info *info)
1438{ 1438{
1439 unsigned int i = 0; 1439 unsigned int i = 0;
1440 struct netfront_queue *queue = NULL;
1441 unsigned int num_queues = info->netdev->real_num_tx_queues; 1440 unsigned int num_queues = info->netdev->real_num_tx_queues;
1442 1441
1442 netif_carrier_off(info->netdev);
1443
1443 for (i = 0; i < num_queues; ++i) { 1444 for (i = 0; i < num_queues; ++i) {
1444 /* Stop old i/f to prevent errors whilst we rebuild the state. */ 1445 struct netfront_queue *queue = &info->queues[i];
1445 spin_lock_bh(&queue->rx_lock);
1446 spin_lock_irq(&queue->tx_lock);
1447 netif_carrier_off(queue->info->netdev);
1448 spin_unlock_irq(&queue->tx_lock);
1449 spin_unlock_bh(&queue->rx_lock);
1450 1446
1451 if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) 1447 if (queue->tx_irq && (queue->tx_irq == queue->rx_irq))
1452 unbind_from_irqhandler(queue->tx_irq, queue); 1448 unbind_from_irqhandler(queue->tx_irq, queue);
@@ -1457,6 +1453,8 @@ static void xennet_disconnect_backend(struct netfront_info *info)
1457 queue->tx_evtchn = queue->rx_evtchn = 0; 1453 queue->tx_evtchn = queue->rx_evtchn = 0;
1458 queue->tx_irq = queue->rx_irq = 0; 1454 queue->tx_irq = queue->rx_irq = 0;
1459 1455
1456 napi_synchronize(&queue->napi);
1457
1460 /* End access and free the pages */ 1458 /* End access and free the pages */
1461 xennet_end_access(queue->tx_ring_ref, queue->tx.sring); 1459 xennet_end_access(queue->tx_ring_ref, queue->tx.sring);
1462 xennet_end_access(queue->rx_ring_ref, queue->rx.sring); 1460 xennet_end_access(queue->rx_ring_ref, queue->rx.sring);
@@ -1698,8 +1696,6 @@ static int xennet_init_queue(struct netfront_queue *queue)
1698 goto exit_free_tx; 1696 goto exit_free_tx;
1699 } 1697 }
1700 1698
1701 netif_napi_add(queue->info->netdev, &queue->napi, xennet_poll, 64);
1702
1703 return 0; 1699 return 0;
1704 1700
1705 exit_free_tx: 1701 exit_free_tx:
@@ -1790,6 +1786,70 @@ error:
1790 return err; 1786 return err;
1791} 1787}
1792 1788
1789static void xennet_destroy_queues(struct netfront_info *info)
1790{
1791 unsigned int i;
1792
1793 rtnl_lock();
1794
1795 for (i = 0; i < info->netdev->real_num_tx_queues; i++) {
1796 struct netfront_queue *queue = &info->queues[i];
1797
1798 if (netif_running(info->netdev))
1799 napi_disable(&queue->napi);
1800 netif_napi_del(&queue->napi);
1801 }
1802
1803 rtnl_unlock();
1804
1805 kfree(info->queues);
1806 info->queues = NULL;
1807}
1808
1809static int xennet_create_queues(struct netfront_info *info,
1810 unsigned int num_queues)
1811{
1812 unsigned int i;
1813 int ret;
1814
1815 info->queues = kcalloc(num_queues, sizeof(struct netfront_queue),
1816 GFP_KERNEL);
1817 if (!info->queues)
1818 return -ENOMEM;
1819
1820 rtnl_lock();
1821
1822 for (i = 0; i < num_queues; i++) {
1823 struct netfront_queue *queue = &info->queues[i];
1824
1825 queue->id = i;
1826 queue->info = info;
1827
1828 ret = xennet_init_queue(queue);
1829 if (ret < 0) {
1830 dev_warn(&info->netdev->dev, "only created %d queues\n",
1831 num_queues);
1832 num_queues = i;
1833 break;
1834 }
1835
1836 netif_napi_add(queue->info->netdev, &queue->napi,
1837 xennet_poll, 64);
1838 if (netif_running(info->netdev))
1839 napi_enable(&queue->napi);
1840 }
1841
1842 netif_set_real_num_tx_queues(info->netdev, num_queues);
1843
1844 rtnl_unlock();
1845
1846 if (num_queues == 0) {
1847 dev_err(&info->netdev->dev, "no queues\n");
1848 return -EINVAL;
1849 }
1850 return 0;
1851}
1852
1793/* Common code used when first setting up, and when resuming. */ 1853/* Common code used when first setting up, and when resuming. */
1794static int talk_to_netback(struct xenbus_device *dev, 1854static int talk_to_netback(struct xenbus_device *dev,
1795 struct netfront_info *info) 1855 struct netfront_info *info)
@@ -1826,42 +1886,20 @@ static int talk_to_netback(struct xenbus_device *dev,
1826 goto out; 1886 goto out;
1827 } 1887 }
1828 1888
1829 /* Allocate array of queues */ 1889 if (info->queues)
1830 info->queues = kcalloc(num_queues, sizeof(struct netfront_queue), GFP_KERNEL); 1890 xennet_destroy_queues(info);
1831 if (!info->queues) { 1891
1832 err = -ENOMEM; 1892 err = xennet_create_queues(info, num_queues);
1833 goto out; 1893 if (err < 0)
1834 } 1894 goto destroy_ring;
1835 rtnl_lock();
1836 netif_set_real_num_tx_queues(info->netdev, num_queues);
1837 rtnl_unlock();
1838 1895
1839 /* Create shared ring, alloc event channel -- for each queue */ 1896 /* Create shared ring, alloc event channel -- for each queue */
1840 for (i = 0; i < num_queues; ++i) { 1897 for (i = 0; i < num_queues; ++i) {
1841 queue = &info->queues[i]; 1898 queue = &info->queues[i];
1842 queue->id = i;
1843 queue->info = info;
1844 err = xennet_init_queue(queue);
1845 if (err) {
1846 /* xennet_init_queue() cleans up after itself on failure,
1847 * but we still have to clean up any previously initialised
1848 * queues. If i > 0, set num_queues to i, then goto
1849 * destroy_ring, which calls xennet_disconnect_backend()
1850 * to tidy up.
1851 */
1852 if (i > 0) {
1853 rtnl_lock();
1854 netif_set_real_num_tx_queues(info->netdev, i);
1855 rtnl_unlock();
1856 goto destroy_ring;
1857 } else {
1858 goto out;
1859 }
1860 }
1861 err = setup_netfront(dev, queue, feature_split_evtchn); 1899 err = setup_netfront(dev, queue, feature_split_evtchn);
1862 if (err) { 1900 if (err) {
1863 /* As for xennet_init_queue(), setup_netfront() will tidy 1901 /* setup_netfront() will tidy up the current
1864 * up the current queue on error, but we need to clean up 1902 * queue on error, but we need to clean up
1865 * those already allocated. 1903 * those already allocated.
1866 */ 1904 */
1867 if (i > 0) { 1905 if (i > 0) {
@@ -2005,13 +2043,15 @@ static int xennet_connect(struct net_device *dev)
2005 /* By now, the queue structures have been set up */ 2043 /* By now, the queue structures have been set up */
2006 for (j = 0; j < num_queues; ++j) { 2044 for (j = 0; j < num_queues; ++j) {
2007 queue = &np->queues[j]; 2045 queue = &np->queues[j];
2008 spin_lock_bh(&queue->rx_lock);
2009 spin_lock_irq(&queue->tx_lock);
2010 2046
2011 /* Step 1: Discard all pending TX packet fragments. */ 2047 /* Step 1: Discard all pending TX packet fragments. */
2048 spin_lock_irq(&queue->tx_lock);
2012 xennet_release_tx_bufs(queue); 2049 xennet_release_tx_bufs(queue);
2050 spin_unlock_irq(&queue->tx_lock);
2013 2051
2014 /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */ 2052 /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */
2053 spin_lock_bh(&queue->rx_lock);
2054
2015 for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) { 2055 for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) {
2016 skb_frag_t *frag; 2056 skb_frag_t *frag;
2017 const struct page *page; 2057 const struct page *page;
@@ -2035,6 +2075,8 @@ static int xennet_connect(struct net_device *dev)
2035 } 2075 }
2036 2076
2037 queue->rx.req_prod_pvt = requeue_idx; 2077 queue->rx.req_prod_pvt = requeue_idx;
2078
2079 spin_unlock_bh(&queue->rx_lock);
2038 } 2080 }
2039 2081
2040 /* 2082 /*
@@ -2046,13 +2088,17 @@ static int xennet_connect(struct net_device *dev)
2046 netif_carrier_on(np->netdev); 2088 netif_carrier_on(np->netdev);
2047 for (j = 0; j < num_queues; ++j) { 2089 for (j = 0; j < num_queues; ++j) {
2048 queue = &np->queues[j]; 2090 queue = &np->queues[j];
2091
2049 notify_remote_via_irq(queue->tx_irq); 2092 notify_remote_via_irq(queue->tx_irq);
2050 if (queue->tx_irq != queue->rx_irq) 2093 if (queue->tx_irq != queue->rx_irq)
2051 notify_remote_via_irq(queue->rx_irq); 2094 notify_remote_via_irq(queue->rx_irq);
2052 xennet_tx_buf_gc(queue);
2053 xennet_alloc_rx_buffers(queue);
2054 2095
2096 spin_lock_irq(&queue->tx_lock);
2097 xennet_tx_buf_gc(queue);
2055 spin_unlock_irq(&queue->tx_lock); 2098 spin_unlock_irq(&queue->tx_lock);
2099
2100 spin_lock_bh(&queue->rx_lock);
2101 xennet_alloc_rx_buffers(queue);
2056 spin_unlock_bh(&queue->rx_lock); 2102 spin_unlock_bh(&queue->rx_lock);
2057 } 2103 }
2058 2104