Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
authorDavid S. Miller <davem@davemloft.net>
Sun, 7 Apr 2013 22:37:01 +0000 (18:37 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 7 Apr 2013 22:37:01 +0000 (18:37 -0400)
Conflicts:
drivers/nfc/microread/mei.c
net/netfilter/nfnetlink_queue_core.c

Pull in 'net' to get Eric Biederman's AF_UNIX fix, upon which
some cleanups are going to go on-top.

Signed-off-by: David S. Miller <davem@davemloft.net>
26 files changed:
1  2 
MAINTAINERS
drivers/net/bonding/bond_main.c
drivers/net/ethernet/atheros/atl1e/atl1e_main.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/realtek/r8169.c
drivers/net/wireless/iwlwifi/dvm/tx.c
drivers/net/wireless/mwifiex/cfg80211.c
include/linux/netdevice.h
include/linux/skbuff.h
net/bluetooth/af_bluetooth.c
net/caif/caif_socket.c
net/core/dev.c
net/ipv4/devinet.c
net/ipv6/netfilter/ip6t_NPT.c
net/ipv6/tcp_ipv6.c
net/iucv/af_iucv.c
net/mac80211/cfg.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/offchannel.c
net/netfilter/nf_conntrack_standalone.c
net/nfc/llcp/llcp.c
net/nfc/llcp/sock.c
net/unix/af_unix.c
net/vmw_vsock/vmci_transport.c

diff --combined MAINTAINERS
index d3a888cfa0eae5b796565aa4697b0cf601d0df6f,376704078d65f2a2920ff15ae802947a6a46cc85..c8f792ae9582b582aef19d2e3ae983e2b51eab39
@@@ -6330,7 -6330,6 +6330,7 @@@ F:      drivers/acpi/apei/erst.
  
  PTP HARDWARE CLOCK SUPPORT
  M:    Richard Cochran <richardcochran@gmail.com>
 +L:    netdev@vger.kernel.org
  S:    Maintained
  W:    http://linuxptp.sourceforge.net/
  F:    Documentation/ABI/testing/sysfs-ptp
@@@ -6462,7 -6461,6 +6462,7 @@@ S:      Supporte
  F:    drivers/net/ethernet/qlogic/qlcnic/
  
  QLOGIC QLGE 10Gb ETHERNET DRIVER
 +M:    Shahed Shaikh <shahed.shaikh@qlogic.com>
  M:    Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>
  M:    Ron Mercer <ron.mercer@qlogic.com>
  M:    linux-driver@qlogic.com
@@@ -6953,7 -6951,6 +6953,6 @@@ F:      drivers/scsi/st
  
  SCTP PROTOCOL
  M:    Vlad Yasevich <vyasevich@gmail.com>
- M:    Sridhar Samudrala <sri@us.ibm.com>
  M:    Neil Horman <nhorman@tuxdriver.com>
  L:    linux-sctp@vger.kernel.org
  W:    http://lksctp.sourceforge.net
@@@ -8517,7 -8514,7 +8516,7 @@@ F:      drivers/usb/gadget/*uvc*.
  F:    drivers/usb/gadget/webcam.c
  
  USB WIRELESS RNDIS DRIVER (rndis_wlan)
 -M:    Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
 +M:    Jussi Kivilinna <jussi.kivilinna@iki.fi>
  L:    linux-wireless@vger.kernel.org
  S:    Maintained
  F:    drivers/net/wireless/rndis_wlan.c
index 78c9e2d33eb7a142707315c612cf7f67eedfdbdd,171b10f167a501a75fe8c7639c6d8dba0953f4b3..2aac890320cba53f5f25b8549aff45fa5e21d83e
@@@ -796,8 -796,9 +796,8 @@@ static void bond_resend_igmp_join_reque
  {
        struct bonding *bond = container_of(work, struct bonding,
                                            mcast_work.work);
 -      rcu_read_lock();
 +
        bond_resend_igmp_join_requests(bond);
 -      rcu_read_unlock();
  }
  
  /*
@@@ -4901,8 -4902,8 +4901,8 @@@ static void __exit bonding_exit(void
  
        bond_destroy_debugfs();
  
-       rtnl_link_unregister(&bond_link_ops);
        unregister_pernet_subsys(&bond_net_ops);
+       rtnl_link_unregister(&bond_link_ops);
  
  #ifdef CONFIG_NET_POLL_CONTROLLER
        /*
index 7e0a822289c327cccbb43030cf7940e2f89e6dad,ac25f05ff68f03b9eda25867d0ace6707efc2d41..d058d0061ed0a25ef88cfeb3ccf3fdee3af2d3ab
@@@ -1420,9 -1420,11 +1420,9 @@@ static void atl1e_clean_rx_irq(struct a
                        packet_size = ((prrs->word1 >> RRS_PKT_SIZE_SHIFT) &
                                        RRS_PKT_SIZE_MASK) - 4; /* CRC */
                        skb = netdev_alloc_skb_ip_align(netdev, packet_size);
 -                      if (skb == NULL) {
 -                              netdev_warn(netdev,
 -                                          "Memory squeeze, deferring packet\n");
 +                      if (skb == NULL)
                                goto skip_pkt;
 -                      }
 +
                        memcpy(skb->data, (u8 *)(prrs + 1), packet_size);
                        skb_put(skb, packet_size);
                        skb->protocol = eth_type_trans(skb, netdev);
@@@ -2327,6 -2329,7 +2327,7 @@@ static int atl1e_probe(struct pci_dev *
  
        INIT_WORK(&adapter->reset_task, atl1e_reset_task);
        INIT_WORK(&adapter->link_chg_task, atl1e_link_chg_task);
+       netif_set_gso_max_size(netdev, MAX_TSO_SEG_SIZE);
        err = register_netdev(netdev);
        if (err) {
                netdev_err(netdev, "register netdevice failed\n");
index 6cc6c6374a924524b8e43b4fc75c8de85964fcc4,0283f343b0d1efd82be8f7fcb8b392823d0111e0..40f58d73de78ae297f38fe7397d3cc35eaf7a28e
  #include "bnx2x.h"
  #include "bnx2x_cmn.h"
  
 +typedef int (*read_sfp_module_eeprom_func_p)(struct bnx2x_phy *phy,
 +                                           struct link_params *params,
 +                                           u8 dev_addr, u16 addr, u8 byte_cnt,
 +                                           u8 *o_buf, u8);
  /********************************************************/
  #define ETH_HLEN                      14
  /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
  #define SFP_EEPROM_CON_TYPE_ADDR              0x2
        #define SFP_EEPROM_CON_TYPE_VAL_LC      0x7
        #define SFP_EEPROM_CON_TYPE_VAL_COPPER  0x21
 +      #define SFP_EEPROM_CON_TYPE_VAL_RJ45    0x22
  
  
  #define SFP_EEPROM_COMP_CODE_ADDR             0x3
@@@ -3132,6 -3127,11 +3132,6 @@@ static int bnx2x_bsc_read(struct link_p
        int rc = 0;
        struct bnx2x *bp = params->bp;
  
 -      if ((sl_devid != 0xa0) && (sl_devid != 0xa2)) {
 -              DP(NETIF_MSG_LINK, "invalid sl_devid 0x%x\n", sl_devid);
 -              return -EINVAL;
 -      }
 -
        if (xfer_cnt > 16) {
                DP(NETIF_MSG_LINK, "invalid xfer_cnt %d. Max is 16 bytes\n",
                                        xfer_cnt);
@@@ -3629,16 -3629,6 +3629,16 @@@ static u8 bnx2x_ext_phy_resolve_fc(stru
   * init configuration, and set/clear SGMII flag. Internal
   * phy init is done purely in phy_init stage.
   */
 +#define WC_TX_DRIVER(post2, idriver, ipre) \
 +      ((post2 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | \
 +       (idriver << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | \
 +       (ipre << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))
 +
 +#define WC_TX_FIR(post, main, pre) \
 +      ((post << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | \
 +       (main << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | \
 +       (pre << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET))
 +
  static void bnx2x_warpcore_enable_AN_KR2(struct bnx2x_phy *phy,
                                         struct link_params *params,
                                         struct link_vars *vars)
@@@ -3738,7 -3728,7 +3738,7 @@@ static void bnx2x_warpcore_enable_AN_KR
        if (((vars->line_speed == SPEED_AUTO_NEG) &&
             (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) ||
            (vars->line_speed == SPEED_1000)) {
 -              u32 addr = MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2;
 +              u16 addr = MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2;
                an_adv |= (1<<5);
  
                /* Enable CL37 1G Parallel Detect */
        /* Set Transmit PMD settings */
        lane = bnx2x_get_warpcore_lane(phy, params);
        bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
 -                    MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane,
 -                   ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) |
 -                    (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) |
 -                    (0x09 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)));
 +                       MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane,
 +                       WC_TX_DRIVER(0x02, 0x06, 0x09));
        /* Configure the next lane if dual mode */
        if (phy->flags & FLAGS_WC_DUAL_MODE)
                bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
                                 MDIO_WC_REG_TX0_TX_DRIVER + 0x10*(lane+1),
 -                               ((0x02 <<
 -                               MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) |
 -                                (0x06 <<
 -                                 MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) |
 -                                (0x09 <<
 -                              MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)));
 +                               WC_TX_DRIVER(0x02, 0x06, 0x09));
        bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
                         MDIO_WC_REG_CL72_USERB0_CL72_OS_DEF_CTRL,
                         0x03f0);
@@@ -3912,8 -3909,6 +3912,8 @@@ static void bnx2x_warpcore_set_10G_XFI(
  {
        struct bnx2x *bp = params->bp;
        u16 misc1_val, tap_val, tx_driver_val, lane, val;
 +      u32 cfg_tap_val, tx_drv_brdct, tx_equal;
 +
        /* Hold rxSeqStart */
        bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD,
                                 MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, 0x8000);
  
        if (is_xfi) {
                misc1_val |= 0x5;
 -              tap_val = ((0x08 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) |
 -                         (0x37 << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) |
 -                         (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET));
 -              tx_driver_val =
 -                    ((0x00 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) |
 -                     (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) |
 -                     (0x03 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET));
 -
 +              tap_val = WC_TX_FIR(0x08, 0x37, 0x00);
 +              tx_driver_val = WC_TX_DRIVER(0x00, 0x02, 0x03);
        } else {
 +              cfg_tap_val = REG_RD(bp, params->shmem_base +
 +                                   offsetof(struct shmem_region, dev_info.
 +                                            port_hw_config[params->port].
 +                                            sfi_tap_values));
 +
 +              tx_equal = cfg_tap_val & PORT_HW_CFG_TX_EQUALIZATION_MASK;
 +
 +              tx_drv_brdct = (cfg_tap_val &
 +                              PORT_HW_CFG_TX_DRV_BROADCAST_MASK) >>
 +                             PORT_HW_CFG_TX_DRV_BROADCAST_SHIFT;
 +
                misc1_val |= 0x9;
 -              tap_val = ((0x0f << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) |
 -                         (0x2b << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) |
 -                         (0x02 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET));
 -              tx_driver_val =
 -                    ((0x03 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) |
 -                     (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) |
 -                     (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET));
 +
 +              /* TAP values are controlled by nvram, if value there isn't 0 */
 +              if (tx_equal)
 +                      tap_val = (u16)tx_equal;
 +              else
 +                      tap_val = WC_TX_FIR(0x0f, 0x2b, 0x02);
 +
 +              if (tx_drv_brdct)
 +                      tx_driver_val = WC_TX_DRIVER(0x03, (u16)tx_drv_brdct,
 +                                                   0x06);
 +              else
 +                      tx_driver_val = WC_TX_DRIVER(0x03, 0x02, 0x06);
        }
        bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
                         MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val);
@@@ -4120,11 -4105,15 +4120,11 @@@ static void bnx2x_warpcore_set_20G_DXGX
        /* Set Transmit PMD settings */
        bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
                         MDIO_WC_REG_TX_FIR_TAP,
 -                      ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) |
 -                       (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) |
 -                       (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET) |
 -                       MDIO_WC_REG_TX_FIR_TAP_ENABLE));
 +                       (WC_TX_FIR(0x12, 0x2d, 0x00) |
 +                        MDIO_WC_REG_TX_FIR_TAP_ENABLE));
        bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
 -                    MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane,
 -                   ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) |
 -                    (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) |
 -                    (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)));
 +                       MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane,
 +                       WC_TX_DRIVER(0x02, 0x02, 0x02));
  }
  
  static void bnx2x_warpcore_set_sgmii_speed(struct bnx2x_phy *phy,
@@@ -4761,8 -4750,8 +4761,8 @@@ void bnx2x_link_status_update(struct li
                                            port_mb[port].link_status));
  
        /* Force link UP in non LOOPBACK_EXT loopback mode(s) */
 -      if (bp->link_params.loopback_mode != LOOPBACK_NONE &&
 -          bp->link_params.loopback_mode != LOOPBACK_EXT)
 +      if (params->loopback_mode != LOOPBACK_NONE &&
 +          params->loopback_mode != LOOPBACK_EXT)
                vars->link_status |= LINK_STATUS_LINK_UP;
  
        if (bnx2x_eee_has_cap(params))
@@@ -7769,8 -7758,7 +7769,8 @@@ static void bnx2x_sfp_set_transmitter(s
  
  static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy,
                                             struct link_params *params,
 -                                           u16 addr, u8 byte_cnt, u8 *o_buf)
 +                                           u8 dev_addr, u16 addr, u8 byte_cnt,
 +                                           u8 *o_buf, u8 is_init)
  {
        struct bnx2x *bp = params->bp;
        u16 val = 0;
        /* Set the read command byte count */
        bnx2x_cl45_write(bp, phy,
                         MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT,
 -                       (byte_cnt | 0xa000));
 +                       (byte_cnt | (dev_addr << 8)));
  
        /* Set the read command address */
        bnx2x_cl45_write(bp, phy,
@@@ -7857,7 -7845,6 +7857,7 @@@ static void bnx2x_warpcore_power_module
  }
  static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy,
                                                 struct link_params *params,
 +                                               u8 dev_addr,
                                                 u16 addr, u8 byte_cnt,
                                                 u8 *o_buf, u8 is_init)
  {
                        usleep_range(1000, 2000);
                        bnx2x_warpcore_power_module(params, 1);
                }
 -              rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt,
 +              rc = bnx2x_bsc_read(params, phy, dev_addr, addr32, 0, byte_cnt,
                                    data_array);
        } while ((rc != 0) && (++cnt < I2C_WA_RETRY_CNT));
  
  
  static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy,
                                             struct link_params *params,
 -                                           u16 addr, u8 byte_cnt, u8 *o_buf)
 +                                           u8 dev_addr, u16 addr, u8 byte_cnt,
 +                                           u8 *o_buf, u8 is_init)
  {
        struct bnx2x *bp = params->bp;
        u16 val, i;
                return -EINVAL;
        }
  
 +      /* Set 2-wire transfer rate of SFP+ module EEPROM
 +       * to 100Khz since some DACs(direct attached cables) do
 +       * not work at 400Khz.
 +       */
 +      bnx2x_cl45_write(bp, phy,
 +                       MDIO_PMA_DEVAD,
 +                       MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR,
 +                       ((dev_addr << 8) | 1));
 +
        /* Need to read from 1.8000 to clear it */
        bnx2x_cl45_read(bp, phy,
                        MDIO_PMA_DEVAD,
  
        return -EINVAL;
  }
 -
  int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy,
 -                               struct link_params *params, u16 addr,
 -                               u8 byte_cnt, u8 *o_buf)
 +                               struct link_params *params, u8 dev_addr,
 +                               u16 addr, u16 byte_cnt, u8 *o_buf)
  {
 -      int rc = -EOPNOTSUPP;
 +      int rc = 0;
 +      struct bnx2x *bp = params->bp;
 +      u8 xfer_size;
 +      u8 *user_data = o_buf;
 +      read_sfp_module_eeprom_func_p read_func;
 +
 +      if ((dev_addr != 0xa0) && (dev_addr != 0xa2)) {
 +              DP(NETIF_MSG_LINK, "invalid dev_addr 0x%x\n", dev_addr);
 +              return -EINVAL;
 +      }
 +
        switch (phy->type) {
        case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726:
 -              rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr,
 -                                                     byte_cnt, o_buf);
 -      break;
 +              read_func = bnx2x_8726_read_sfp_module_eeprom;
 +              break;
        case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727:
        case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722:
 -              rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr,
 -                                                     byte_cnt, o_buf);
 -      break;
 +              read_func = bnx2x_8727_read_sfp_module_eeprom;
 +              break;
        case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT:
 -              rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr,
 -                                                         byte_cnt, o_buf, 0);
 -      break;
 +              read_func = bnx2x_warpcore_read_sfp_module_eeprom;
 +              break;
 +      default:
 +              return -EOPNOTSUPP;
 +      }
 +
 +      while (!rc && (byte_cnt > 0)) {
 +              xfer_size = (byte_cnt > SFP_EEPROM_PAGE_SIZE) ?
 +                      SFP_EEPROM_PAGE_SIZE : byte_cnt;
 +              rc = read_func(phy, params, dev_addr, addr, xfer_size,
 +                             user_data, 0);
 +              byte_cnt -= xfer_size;
 +              user_data += xfer_size;
 +              addr += xfer_size;
        }
        return rc;
  }
@@@ -8045,7 -8004,6 +8045,7 @@@ static int bnx2x_get_edc_mode(struct bn
        /* First check for copper cable */
        if (bnx2x_read_sfp_module_eeprom(phy,
                                         params,
 +                                       I2C_DEV_ADDR_A0,
                                         SFP_EEPROM_CON_TYPE_ADDR,
                                         2,
                                         (u8 *)val) != 0) {
                 */
                if (bnx2x_read_sfp_module_eeprom(phy,
                                               params,
 +                                             I2C_DEV_ADDR_A0,
                                               SFP_EEPROM_FC_TX_TECH_ADDR,
                                               1,
                                               &copper_module_type) != 0) {
                break;
        }
        case SFP_EEPROM_CON_TYPE_VAL_LC:
 +      case SFP_EEPROM_CON_TYPE_VAL_RJ45:
                check_limiting_mode = 1;
                if ((val[1] & (SFP_EEPROM_COMP_CODE_SR_MASK |
                               SFP_EEPROM_COMP_CODE_LR_MASK |
                               SFP_EEPROM_COMP_CODE_LRM_MASK)) == 0) {
 -                      DP(NETIF_MSG_LINK, "1G Optic module detected\n");
 +                      DP(NETIF_MSG_LINK, "1G SFP module detected\n");
                        gport = params->port;
                        phy->media_type = ETH_PHY_SFP_1G_FIBER;
 -                      phy->req_line_speed = SPEED_1000;
 -                      if (!CHIP_IS_E1x(bp))
 -                              gport = BP_PATH(bp) + (params->port << 1);
 -                      netdev_err(bp->dev, "Warning: Link speed was forced to 1000Mbps."
 -                            " Current SFP module in port %d is not"
 -                            " compliant with 10G Ethernet\n",
 -                       gport);
 +                      if (phy->req_line_speed != SPEED_1000) {
 +                              phy->req_line_speed = SPEED_1000;
 +                              if (!CHIP_IS_E1x(bp)) {
 +                                      gport = BP_PATH(bp) +
 +                                      (params->port << 1);
 +                              }
 +                              netdev_err(bp->dev,
 +                                         "Warning: Link speed was forced to 1000Mbps. Current SFP module in port %d is not compliant with 10G Ethernet\n",
 +                                         gport);
 +                      }
                } else {
                        int idx, cfg_idx = 0;
                        DP(NETIF_MSG_LINK, "10G Optic module detected\n");
                u8 options[SFP_EEPROM_OPTIONS_SIZE];
                if (bnx2x_read_sfp_module_eeprom(phy,
                                                 params,
 +                                               I2C_DEV_ADDR_A0,
                                                 SFP_EEPROM_OPTIONS_ADDR,
                                                 SFP_EEPROM_OPTIONS_SIZE,
                                                 options) != 0) {
@@@ -8215,7 -8167,6 +8215,7 @@@ static int bnx2x_verify_sfp_module(stru
        /* Format the warning message */
        if (bnx2x_read_sfp_module_eeprom(phy,
                                         params,
 +                                       I2C_DEV_ADDR_A0,
                                         SFP_EEPROM_VENDOR_NAME_ADDR,
                                         SFP_EEPROM_VENDOR_NAME_SIZE,
                                         (u8 *)vendor_name))
                vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0';
        if (bnx2x_read_sfp_module_eeprom(phy,
                                         params,
 +                                       I2C_DEV_ADDR_A0,
                                         SFP_EEPROM_PART_NO_ADDR,
                                         SFP_EEPROM_PART_NO_SIZE,
                                         (u8 *)vendor_pn))
@@@ -8255,13 -8205,12 +8255,13 @@@ static int bnx2x_wait_for_sfp_module_in
  
        for (timeout = 0; timeout < 60; timeout++) {
                if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT)
 -                      rc = bnx2x_warpcore_read_sfp_module_eeprom(phy,
 -                                                                 params, 1,
 -                                                                 1, &val, 1);
 +                      rc = bnx2x_warpcore_read_sfp_module_eeprom(
 +                              phy, params, I2C_DEV_ADDR_A0, 1, 1, &val,
 +                              1);
                else
 -                      rc = bnx2x_read_sfp_module_eeprom(phy, params, 1, 1,
 -                                                        &val);
 +                      rc = bnx2x_read_sfp_module_eeprom(phy, params,
 +                                                        I2C_DEV_ADDR_A0,
 +                                                        1, 1, &val);
                if (rc == 0) {
                        DP(NETIF_MSG_LINK,
                           "SFP+ module initialization took %d ms\n",
                }
                usleep_range(5000, 10000);
        }
 -      rc = bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val);
 +      rc = bnx2x_read_sfp_module_eeprom(phy, params, I2C_DEV_ADDR_A0,
 +                                        1, 1, &val);
        return rc;
  }
  
@@@ -8428,6 -8376,15 +8428,6 @@@ static void bnx2x_8727_specific_func(st
                bnx2x_cl45_write(bp, phy,
                                 MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL,
                                 val);
 -
 -              /* Set 2-wire transfer rate of SFP+ module EEPROM
 -               * to 100Khz since some DACs(direct attached cables) do
 -               * not work at 400Khz.
 -               */
 -              bnx2x_cl45_write(bp, phy,
 -                               MDIO_PMA_DEVAD,
 -                               MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR,
 -                               0xa001);
                break;
        default:
                DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n",
@@@ -9571,7 -9528,8 +9571,7 @@@ static void bnx2x_save_848xx_spirom_ver
        } else {
                /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */
                /* (1) set reg 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
 -              for (i = 0; i < ARRAY_SIZE(reg_set);
 -                    i++)
 +              for (i = 0; i < ARRAY_SIZE(reg_set); i++)
                        bnx2x_cl45_write(bp, phy, reg_set[i].devad,
                                         reg_set[i].reg, reg_set[i].val);
  
@@@ -10323,8 -10281,7 +10323,8 @@@ static u8 bnx2x_848xx_read_status(struc
                                LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE;
  
                /* Determine if EEE was negotiated */
 -              if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833)
 +              if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) ||
 +                  (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84834))
                        bnx2x_eee_an_resolve(phy, params, vars);
        }
  
@@@ -12285,7 -12242,7 +12285,7 @@@ static void bnx2x_init_bmac_loopback(st
  
                bnx2x_xgxs_deassert(params);
  
 -              /* set bmac loopback */
 +              /* Set bmac loopback */
                bnx2x_bmac_enable(params, vars, 1, 1);
  
                REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0);
@@@ -12304,7 -12261,7 +12304,7 @@@ static void bnx2x_init_emac_loopback(st
                vars->phy_flags = PHY_XGXS_FLAG;
  
                bnx2x_xgxs_deassert(params);
 -              /* set bmac loopback */
 +              /* Set bmac loopback */
                bnx2x_emac_enable(params, vars, 1);
                bnx2x_emac_program(params, vars);
                REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0);
@@@ -12564,7 -12521,6 +12564,7 @@@ int bnx2x_phy_init(struct link_params *
                   params->req_line_speed[0], params->req_flow_ctrl[0]);
        DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n",
                   params->req_line_speed[1], params->req_flow_ctrl[1]);
 +      DP(NETIF_MSG_LINK, "req_adv_flow_ctrl 0x%x\n", params->req_fc_auto_adv);
        vars->link_status = 0;
        vars->phy_link_up = 0;
        vars->link_up = 0;
@@@ -13481,23 -13437,27 +13481,27 @@@ static void bnx2x_check_kr2_wa(struct l
  {
        struct bnx2x *bp = params->bp;
        u16 base_page, next_page, not_kr2_device, lane;
-       int sigdet = bnx2x_warpcore_get_sigdet(phy, params);
-       if (!sigdet) {
-               if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE))
-                       bnx2x_kr2_recovery(params, vars, phy);
-               return;
-       }
+       int sigdet;
  
        /* Once KR2 was disabled, wait 5 seconds before checking KR2 recovery
 -       * since some switches tend to reinit the AN process and clear the
 -       * advertised BP/NP after ~2 seconds causing the KR2 to be disabled
 +       * Since some switches tend to reinit the AN process and clear the
 +       * the advertised BP/NP after ~2 seconds causing the KR2 to be disabled
         * and recovered many times
         */
        if (vars->check_kr2_recovery_cnt > 0) {
                vars->check_kr2_recovery_cnt--;
                return;
        }
+       sigdet = bnx2x_warpcore_get_sigdet(phy, params);
+       if (!sigdet) {
+               if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {
+                       bnx2x_kr2_recovery(params, vars, phy);
+                       DP(NETIF_MSG_LINK, "No sigdet\n");
+               }
+               return;
+       }
        lane = bnx2x_get_warpcore_lane(phy, params);
        CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK,
                          MDIO_AER_BLOCK_AER_REG, lane);
  
        /* CL73 has not begun yet */
        if (base_page == 0) {
 -              if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE))
 +              if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {
                        bnx2x_kr2_recovery(params, vars, phy);
 +                      DP(NETIF_MSG_LINK, "No BP\n");
 +              }
                return;
        }
  
        if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {
                if (!not_kr2_device) {
                        DP(NETIF_MSG_LINK, "BP=0x%x, NP=0x%x\n", base_page,
 -                                     next_page);
 +                         next_page);
                        bnx2x_kr2_recovery(params, vars, phy);
                }
                return;
index e56a3d169e30f0d85ac959de07f063d371e99b09,79f4a26ea6cc580c1b23cd72fee362c3c495880a..1339932f59b151c187865f5836c92db10bf4aded
@@@ -7007,7 -7007,7 +7007,7 @@@ static int ixgbe_ndo_fdb_add(struct ndm
        int err;
  
        if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
 -              return -EOPNOTSUPP;
 +              return ndo_dflt_fdb_add(ndm, tb, dev, addr, flags);
  
        /* Hardware does not support aging addresses so if a
         * ndm_state is given only allow permanent addresses
        return err;
  }
  
 -static int ixgbe_ndo_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
 -                           struct net_device *dev,
 -                           const unsigned char *addr)
 -{
 -      struct ixgbe_adapter *adapter = netdev_priv(dev);
 -      int err = -EOPNOTSUPP;
 -
 -      if (ndm->ndm_state & NUD_PERMANENT) {
 -              pr_info("%s: FDB only supports static addresses\n",
 -                      ixgbe_driver_name);
 -              return -EINVAL;
 -      }
 -
 -      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
 -              if (is_unicast_ether_addr(addr))
 -                      err = dev_uc_del(dev, addr);
 -              else if (is_multicast_ether_addr(addr))
 -                      err = dev_mc_del(dev, addr);
 -              else
 -                      err = -EINVAL;
 -      }
 -
 -      return err;
 -}
 -
 -static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
 -                            struct netlink_callback *cb,
 -                            struct net_device *dev,
 -                            int idx)
 -{
 -      struct ixgbe_adapter *adapter = netdev_priv(dev);
 -
 -      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 -              idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
 -
 -      return idx;
 -}
 -
  static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
                                    struct nlmsghdr *nlh)
  {
@@@ -7133,6 -7171,8 +7133,6 @@@ static const struct net_device_ops ixgb
        .ndo_set_features = ixgbe_set_features,
        .ndo_fix_features = ixgbe_fix_features,
        .ndo_fdb_add            = ixgbe_ndo_fdb_add,
 -      .ndo_fdb_del            = ixgbe_ndo_fdb_del,
 -      .ndo_fdb_dump           = ixgbe_ndo_fdb_dump,
        .ndo_bridge_setlink     = ixgbe_ndo_bridge_setlink,
        .ndo_bridge_getlink     = ixgbe_ndo_bridge_getlink,
  };
@@@ -7882,12 -7922,19 +7882,19 @@@ static int __init ixgbe_init_module(voi
        ixgbe_dbg_init();
  #endif /* CONFIG_DEBUG_FS */
  
+       ret = pci_register_driver(&ixgbe_driver);
+       if (ret) {
+ #ifdef CONFIG_DEBUG_FS
+               ixgbe_dbg_exit();
+ #endif /* CONFIG_DEBUG_FS */
+               return ret;
+       }
  #ifdef CONFIG_IXGBE_DCA
        dca_register_notify(&dca_notifier);
  #endif
  
-       ret = pci_register_driver(&ixgbe_driver);
-       return ret;
+       return 0;
  }
  
  module_init(ixgbe_init_module);
index e392dd021b19069a94bf053fd0a3d4b4776c0bed,4ecbe64a758d8b05dd5a016a9659b20bfdfb90c5..9a1bc1a238542d8ab9db05a3f4cb9d0078fec97e
@@@ -47,9 -47,7 +47,9 @@@
  #define FIRMWARE_8402_1               "rtl_nic/rtl8402-1.fw"
  #define FIRMWARE_8411_1               "rtl_nic/rtl8411-1.fw"
  #define FIRMWARE_8106E_1      "rtl_nic/rtl8106e-1.fw"
 -#define FIRMWARE_8168G_1      "rtl_nic/rtl8168g-1.fw"
 +#define FIRMWARE_8106E_2      "rtl_nic/rtl8106e-2.fw"
 +#define FIRMWARE_8168G_2      "rtl_nic/rtl8168g-2.fw"
 +#define FIRMWARE_8168G_3      "rtl_nic/rtl8168g-3.fw"
  
  #ifdef RTL8169_DEBUG
  #define assert(expr) \
@@@ -142,8 -140,6 +142,8 @@@ enum mac_version 
        RTL_GIGA_MAC_VER_39,
        RTL_GIGA_MAC_VER_40,
        RTL_GIGA_MAC_VER_41,
 +      RTL_GIGA_MAC_VER_42,
 +      RTL_GIGA_MAC_VER_43,
        RTL_GIGA_MAC_NONE   = 0xff,
  };
  
@@@ -266,16 -262,10 +266,16 @@@ static const struct 
                _R("RTL8106e",          RTL_TD_1, FIRMWARE_8106E_1,
                                                        JUMBO_1K, true),
        [RTL_GIGA_MAC_VER_40] =
 -              _R("RTL8168g/8111g",    RTL_TD_1, FIRMWARE_8168G_1,
 +              _R("RTL8168g/8111g",    RTL_TD_1, FIRMWARE_8168G_2,
                                                        JUMBO_9K, false),
        [RTL_GIGA_MAC_VER_41] =
                _R("RTL8168g/8111g",    RTL_TD_1, NULL, JUMBO_9K, false),
 +      [RTL_GIGA_MAC_VER_42] =
 +              _R("RTL8168g/8111g",    RTL_TD_1, FIRMWARE_8168G_3,
 +                                                      JUMBO_9K, false),
 +      [RTL_GIGA_MAC_VER_43] =
 +              _R("RTL8106e",          RTL_TD_1, FIRMWARE_8106E_2,
 +                                                      JUMBO_1K, true),
  };
  #undef _R
  
@@@ -339,7 -329,6 +339,7 @@@ enum rtl_registers 
  #define       RXCFG_FIFO_SHIFT                13
                                        /* No threshold before first PCI xfer */
  #define       RX_FIFO_THRESH                  (7 << RXCFG_FIFO_SHIFT)
 +#define       RX_EARLY_OFF                    (1 << 11)
  #define       RXCFG_DMA_SHIFT                 8
                                        /* Unlimited maximum PCI burst. */
  #define       RX_DMA_BURST                    (7 << RXCFG_DMA_SHIFT)
@@@ -524,7 -513,6 +524,7 @@@ enum rtl_register_content 
        PMEnable        = (1 << 0),     /* Power Management Enable */
  
        /* Config2 register p. 25 */
 +      ClkReqEn        = (1 << 7),     /* Clock Request Enable */
        MSIEnable       = (1 << 5),     /* 8169 only. Reserved in the 8168. */
        PCI_Clock_66MHz = 0x01,
        PCI_Clock_33MHz = 0x00,
        Spi_en          = (1 << 3),
        LanWake         = (1 << 1),     /* LanWake enable/disable */
        PMEStatus       = (1 << 0),     /* PME status can be reset by PCI RST# */
 +      ASPM_en         = (1 << 0),     /* ASPM enable */
  
        /* TBICSR p.28 */
        TBIReset        = 0x80000000,
@@@ -827,9 -814,7 +827,9 @@@ MODULE_FIRMWARE(FIRMWARE_8168F_2)
  MODULE_FIRMWARE(FIRMWARE_8402_1);
  MODULE_FIRMWARE(FIRMWARE_8411_1);
  MODULE_FIRMWARE(FIRMWARE_8106E_1);
 -MODULE_FIRMWARE(FIRMWARE_8168G_1);
 +MODULE_FIRMWARE(FIRMWARE_8106E_2);
 +MODULE_FIRMWARE(FIRMWARE_8168G_2);
 +MODULE_FIRMWARE(FIRMWARE_8168G_3);
  
  static void rtl_lock_work(struct rtl8169_private *tp)
  {
@@@ -1039,6 -1024,14 +1039,6 @@@ static u16 r8168_phy_ocp_read(struct rt
                (RTL_R32(GPHY_OCP) & 0xffff) : ~0;
  }
  
 -static void rtl_w1w0_phy_ocp(struct rtl8169_private *tp, int reg, int p, int m)
 -{
 -      int val;
 -
 -      val = r8168_phy_ocp_read(tp, reg);
 -      r8168_phy_ocp_write(tp, reg, (val | p) & ~m);
 -}
 -
  static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
  {
        void __iomem *ioaddr = tp->mmio_addr;
@@@ -1084,21 -1077,6 +1084,21 @@@ static int r8168g_mdio_read(struct rtl8
        return r8168_phy_ocp_read(tp, tp->ocp_base + reg * 2);
  }
  
 +static void mac_mcu_write(struct rtl8169_private *tp, int reg, int value)
 +{
 +      if (reg == 0x1f) {
 +              tp->ocp_base = value << 4;
 +              return;
 +      }
 +
 +      r8168_mac_ocp_write(tp, tp->ocp_base + reg, value);
 +}
 +
 +static int mac_mcu_read(struct rtl8169_private *tp, int reg)
 +{
 +      return r8168_mac_ocp_read(tp, tp->ocp_base + reg);
 +}
 +
  DECLARE_RTL_COND(rtl_phyar_cond)
  {
        void __iomem *ioaddr = tp->mmio_addr;
@@@ -2050,7 -2028,6 +2050,7 @@@ static void rtl8169_get_mac_version(str
                int mac_version;
        } mac_info[] = {
                /* 8168G family. */
 +              { 0x7cf00000, 0x50900000,       RTL_GIGA_MAC_VER_42 },
                { 0x7cf00000, 0x4c100000,       RTL_GIGA_MAC_VER_41 },
                { 0x7cf00000, 0x4c000000,       RTL_GIGA_MAC_VER_40 },
  
                netif_notice(tp, probe, dev,
                             "unknown MAC, using family default\n");
                tp->mac_version = default_version;
 +      } else if (tp->mac_version == RTL_GIGA_MAC_VER_42) {
 +              tp->mac_version = tp->mii.supports_gmii ?
 +                                RTL_GIGA_MAC_VER_42 :
 +                                RTL_GIGA_MAC_VER_43;
        }
  }
  
@@@ -2169,7 -2142,9 +2169,7 @@@ static void rtl_writephy_batch(struct r
  #define PHY_DATA_OR           0x10000000
  #define PHY_DATA_AND          0x20000000
  #define PHY_BJMPN             0x30000000
 -#define PHY_READ_EFUSE                0x40000000
 -#define PHY_READ_MAC_BYTE     0x50000000
 -#define PHY_WRITE_MAC_BYTE    0x60000000
 +#define PHY_MDIO_CHG          0x40000000
  #define PHY_CLEAR_READCOUNT   0x70000000
  #define PHY_WRITE             0x80000000
  #define PHY_READCOUNT_EQ_SKIP 0x90000000
  #define PHY_WRITE_PREVIOUS    0xc0000000
  #define PHY_SKIPN             0xd0000000
  #define PHY_DELAY_MS          0xe0000000
 -#define PHY_WRITE_ERI_WORD    0xf0000000
  
  struct fw_info {
        u32     magic;
@@@ -2254,7 -2230,7 +2254,7 @@@ static bool rtl_fw_data_ok(struct rtl81
                case PHY_READ:
                case PHY_DATA_OR:
                case PHY_DATA_AND:
 -              case PHY_READ_EFUSE:
 +              case PHY_MDIO_CHG:
                case PHY_CLEAR_READCOUNT:
                case PHY_WRITE:
                case PHY_WRITE_PREVIOUS:
                        }
                        break;
  
 -              case PHY_READ_MAC_BYTE:
 -              case PHY_WRITE_MAC_BYTE:
 -              case PHY_WRITE_ERI_WORD:
                default:
                        netif_err(tp, ifup, tp->dev,
                                  "Invalid action 0x%08x\n", action);
  static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
  {
        struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
 +      struct mdio_ops org, *ops = &tp->mdio_ops;
        u32 predata, count;
        size_t index;
  
        predata = count = 0;
 +      org.write = ops->write;
 +      org.read = ops->read;
  
        for (index = 0; index < pa->size; ) {
                u32 action = le32_to_cpu(pa->code[index]);
                case PHY_BJMPN:
                        index -= regno;
                        break;
 -              case PHY_READ_EFUSE:
 -                      predata = rtl8168d_efuse_read(tp, regno);
 +              case PHY_MDIO_CHG:
 +                      if (data == 0) {
 +                              ops->write = org.write;
 +                              ops->read = org.read;
 +                      } else if (data == 1) {
 +                              ops->write = mac_mcu_write;
 +                              ops->read = mac_mcu_read;
 +                      }
 +
                        index++;
                        break;
                case PHY_CLEAR_READCOUNT:
                        index++;
                        break;
  
 -              case PHY_READ_MAC_BYTE:
 -              case PHY_WRITE_MAC_BYTE:
 -              case PHY_WRITE_ERI_WORD:
                default:
                        BUG();
                }
        }
 +
 +      ops->write = org.write;
 +      ops->read = org.read;
  }
  
  static void rtl_release_firmware(struct rtl8169_private *tp)
@@@ -3399,68 -3368,51 +3399,68 @@@ static void rtl8411_hw_phy_config(struc
  
  static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp)
  {
 -      static const u16 mac_ocp_patch[] = {
 -              0xe008, 0xe01b, 0xe01d, 0xe01f,
 -              0xe021, 0xe023, 0xe025, 0xe027,
 -              0x49d2, 0xf10d, 0x766c, 0x49e2,
 -              0xf00a, 0x1ec0, 0x8ee1, 0xc60a,
 -
 -              0x77c0, 0x4870, 0x9fc0, 0x1ea0,
 -              0xc707, 0x8ee1, 0x9d6c, 0xc603,
 -              0xbe00, 0xb416, 0x0076, 0xe86c,
 -              0xc602, 0xbe00, 0x0000, 0xc602,
 -
 -              0xbe00, 0x0000, 0xc602, 0xbe00,
 -              0x0000, 0xc602, 0xbe00, 0x0000,
 -              0xc602, 0xbe00, 0x0000, 0xc602,
 -              0xbe00, 0x0000, 0xc602, 0xbe00,
 -
 -              0x0000, 0x0000, 0x0000, 0x0000
 -      };
 -      u32 i;
 +      rtl_apply_firmware(tp);
  
 -      /* Patch code for GPHY reset */
 -      for (i = 0; i < ARRAY_SIZE(mac_ocp_patch); i++)
 -              r8168_mac_ocp_write(tp, 0xf800 + 2*i, mac_ocp_patch[i]);
 -      r8168_mac_ocp_write(tp, 0xfc26, 0x8000);
 -      r8168_mac_ocp_write(tp, 0xfc28, 0x0075);
 +      rtl_writephy(tp, 0x1f, 0x0a46);
 +      if (rtl_readphy(tp, 0x10) & 0x0100) {
 +              rtl_writephy(tp, 0x1f, 0x0bcc);
 +              rtl_w1w0_phy(tp, 0x12, 0x0000, 0x8000);
 +      } else {
 +              rtl_writephy(tp, 0x1f, 0x0bcc);
 +              rtl_w1w0_phy(tp, 0x12, 0x8000, 0x0000);
 +      }
  
 -      rtl_apply_firmware(tp);
 +      rtl_writephy(tp, 0x1f, 0x0a46);
 +      if (rtl_readphy(tp, 0x13) & 0x0100) {
 +              rtl_writephy(tp, 0x1f, 0x0c41);
 +              rtl_w1w0_phy(tp, 0x15, 0x0002, 0x0000);
 +      } else {
 +              rtl_writephy(tp, 0x1f, 0x0c41);
 +              rtl_w1w0_phy(tp, 0x15, 0x0000, 0x0002);
 +      }
  
 -      if (r8168_phy_ocp_read(tp, 0xa460) & 0x0100)
 -              rtl_w1w0_phy_ocp(tp, 0xbcc4, 0x0000, 0x8000);
 -      else
 -              rtl_w1w0_phy_ocp(tp, 0xbcc4, 0x8000, 0x0000);
 +      /* Enable PHY auto speed down */
 +      rtl_writephy(tp, 0x1f, 0x0a44);
 +      rtl_w1w0_phy(tp, 0x11, 0x000c, 0x0000);
 +
 +      rtl_writephy(tp, 0x1f, 0x0bcc);
 +      rtl_w1w0_phy(tp, 0x14, 0x0100, 0x0000);
 +      rtl_writephy(tp, 0x1f, 0x0a44);
 +      rtl_w1w0_phy(tp, 0x11, 0x00c0, 0x0000);
 +      rtl_writephy(tp, 0x1f, 0x0a43);
 +      rtl_writephy(tp, 0x13, 0x8084);
 +      rtl_w1w0_phy(tp, 0x14, 0x0000, 0x6000);
 +      rtl_w1w0_phy(tp, 0x10, 0x1003, 0x0000);
 +
 +      /* EEE auto-fallback function */
 +      rtl_writephy(tp, 0x1f, 0x0a4b);
 +      rtl_w1w0_phy(tp, 0x11, 0x0004, 0x0000);
 +
 +      /* Enable UC LPF tune function */
 +      rtl_writephy(tp, 0x1f, 0x0a43);
 +      rtl_writephy(tp, 0x13, 0x8012);
 +      rtl_w1w0_phy(tp, 0x14, 0x8000, 0x0000);
  
 -      if (r8168_phy_ocp_read(tp, 0xa466) & 0x0100)
 -              rtl_w1w0_phy_ocp(tp, 0xc41a, 0x0002, 0x0000);
 -      else
 -              rtl_w1w0_phy_ocp(tp, 0xbcc4, 0x0000, 0x0002);
 +      rtl_writephy(tp, 0x1f, 0x0c42);
 +      rtl_w1w0_phy(tp, 0x11, 0x4000, 0x2000);
  
 -      rtl_w1w0_phy_ocp(tp, 0xa442, 0x000c, 0x0000);
 -      rtl_w1w0_phy_ocp(tp, 0xa4b2, 0x0004, 0x0000);
 +      /* Improve SWR Efficiency */
 +      rtl_writephy(tp, 0x1f, 0x0bcd);
 +      rtl_writephy(tp, 0x14, 0x5065);
 +      rtl_writephy(tp, 0x14, 0xd065);
 +      rtl_writephy(tp, 0x1f, 0x0bc8);
 +      rtl_writephy(tp, 0x11, 0x5655);
 +      rtl_writephy(tp, 0x1f, 0x0bcd);
 +      rtl_writephy(tp, 0x14, 0x1065);
 +      rtl_writephy(tp, 0x14, 0x9065);
 +      rtl_writephy(tp, 0x14, 0x1065);
  
 -      r8168_phy_ocp_write(tp, 0xa436, 0x8012);
 -      rtl_w1w0_phy_ocp(tp, 0xa438, 0x8000, 0x0000);
 +      rtl_writephy(tp, 0x1f, 0x0000);
 +}
  
 -      rtl_w1w0_phy_ocp(tp, 0xc422, 0x4000, 0x2000);
 +static void rtl8168g_2_hw_phy_config(struct rtl8169_private *tp)
 +{
 +      rtl_apply_firmware(tp);
  }
  
  static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
@@@ -3648,10 -3600,6 +3648,10 @@@ static void rtl_hw_phy_config(struct ne
        case RTL_GIGA_MAC_VER_40:
                rtl8168g_1_hw_phy_config(tp);
                break;
 +      case RTL_GIGA_MAC_VER_42:
 +      case RTL_GIGA_MAC_VER_43:
 +              rtl8168g_2_hw_phy_config(tp);
 +              break;
  
        case RTL_GIGA_MAC_VER_41:
        default:
@@@ -3860,8 -3808,6 +3860,8 @@@ static void rtl_init_mdio_ops(struct rt
                break;
        case RTL_GIGA_MAC_VER_40:
        case RTL_GIGA_MAC_VER_41:
 +      case RTL_GIGA_MAC_VER_42:
 +      case RTL_GIGA_MAC_VER_43:
                ops->write      = r8168g_mdio_write;
                ops->read       = r8168g_mdio_read;
                break;
        }
  }
  
+ static void rtl_speed_down(struct rtl8169_private *tp)
+ {
+       u32 adv;
+       int lpa;
+       rtl_writephy(tp, 0x1f, 0x0000);
+       lpa = rtl_readphy(tp, MII_LPA);
+       if (lpa & (LPA_10HALF | LPA_10FULL))
+               adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;
+       else if (lpa & (LPA_100HALF | LPA_100FULL))
+               adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
+                     ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
+       else
+               adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
+                     ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
+                     (tp->mii.supports_gmii ?
+                      ADVERTISED_1000baseT_Half |
+                      ADVERTISED_1000baseT_Full : 0);
+       rtl8169_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
+                         adv);
+ }
  static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
  {
        void __iomem *ioaddr = tp->mmio_addr;
        case RTL_GIGA_MAC_VER_39:
        case RTL_GIGA_MAC_VER_40:
        case RTL_GIGA_MAC_VER_41:
 +      case RTL_GIGA_MAC_VER_42:
 +      case RTL_GIGA_MAC_VER_43:
                RTL_W32(RxConfig, RTL_R32(RxConfig) |
                        AcceptBroadcast | AcceptMulticast | AcceptMyPhys);
                break;
@@@ -3904,9 -3872,7 +3928,7 @@@ static bool rtl_wol_pll_power_down(stru
        if (!(__rtl8169_get_wol(tp) & WAKE_ANY))
                return false;
  
-       rtl_writephy(tp, 0x1f, 0x0000);
-       rtl_writephy(tp, MII_BMCR, 0x0000);
+       rtl_speed_down(tp);
        rtl_wol_suspend_quirk(tp);
  
        return true;
@@@ -4000,8 -3966,6 +4022,8 @@@ static void r8168_phy_power_down(struc
        switch (tp->mac_version) {
        case RTL_GIGA_MAC_VER_32:
        case RTL_GIGA_MAC_VER_33:
 +      case RTL_GIGA_MAC_VER_40:
 +      case RTL_GIGA_MAC_VER_41:
                rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE | BMCR_PDOWN);
                break;
  
@@@ -4063,11 -4027,6 +4085,11 @@@ static void r8168_pll_power_down(struc
        case RTL_GIGA_MAC_VER_33:
                RTL_W8(PMCH, RTL_R8(PMCH) & ~0x80);
                break;
 +      case RTL_GIGA_MAC_VER_40:
 +      case RTL_GIGA_MAC_VER_41:
 +              rtl_w1w0_eri(tp, 0x1a8, ERIAR_MASK_1111, 0x00000000,
 +                           0xfc000000, ERIAR_EXGMAC);
 +              break;
        }
  }
  
@@@ -4085,11 -4044,6 +4107,11 @@@ static void r8168_pll_power_up(struct r
        case RTL_GIGA_MAC_VER_33:
                RTL_W8(PMCH, RTL_R8(PMCH) | 0x80);
                break;
 +      case RTL_GIGA_MAC_VER_40:
 +      case RTL_GIGA_MAC_VER_41:
 +              rtl_w1w0_eri(tp, 0x1a8, ERIAR_MASK_1111, 0xfc000000,
 +                           0x00000000, ERIAR_EXGMAC);
 +              break;
        }
  
        r8168_phy_power_up(tp);
@@@ -4126,7 -4080,6 +4148,7 @@@ static void rtl_init_pll_power_ops(stru
        case RTL_GIGA_MAC_VER_30:
        case RTL_GIGA_MAC_VER_37:
        case RTL_GIGA_MAC_VER_39:
 +      case RTL_GIGA_MAC_VER_43:
                ops->down       = r810x_pll_power_down;
                ops->up         = r810x_pll_power_up;
                break;
        case RTL_GIGA_MAC_VER_38:
        case RTL_GIGA_MAC_VER_40:
        case RTL_GIGA_MAC_VER_41:
 +      case RTL_GIGA_MAC_VER_42:
                ops->down       = r8168_pll_power_down;
                ops->up         = r8168_pll_power_up;
                break;
@@@ -4197,12 -4149,6 +4219,12 @@@ static void rtl_init_rxcfg(struct rtl81
        case RTL_GIGA_MAC_VER_34:
                RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
                break;
 +      case RTL_GIGA_MAC_VER_40:
 +      case RTL_GIGA_MAC_VER_41:
 +      case RTL_GIGA_MAC_VER_42:
 +      case RTL_GIGA_MAC_VER_43:
 +              RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF);
 +              break;
        default:
                RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST);
                break;
@@@ -4359,8 -4305,6 +4381,8 @@@ static void rtl_init_jumbo_ops(struct r
         */
        case RTL_GIGA_MAC_VER_40:
        case RTL_GIGA_MAC_VER_41:
 +      case RTL_GIGA_MAC_VER_42:
 +      case RTL_GIGA_MAC_VER_43:
        default:
                ops->disable    = NULL;
                ops->enable     = NULL;
@@@ -4468,8 -4412,6 +4490,8 @@@ static void rtl8169_hw_reset(struct rtl
                   tp->mac_version == RTL_GIGA_MAC_VER_37 ||
                   tp->mac_version == RTL_GIGA_MAC_VER_40 ||
                   tp->mac_version == RTL_GIGA_MAC_VER_41 ||
 +                 tp->mac_version == RTL_GIGA_MAC_VER_42 ||
 +                 tp->mac_version == RTL_GIGA_MAC_VER_43 ||
                   tp->mac_version == RTL_GIGA_MAC_VER_38) {
                RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq);
                rtl_udelay_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666);
@@@ -5185,8 -5127,6 +5207,8 @@@ static void rtl_hw_start_8168g_1(struc
        void __iomem *ioaddr = tp->mmio_addr;
        struct pci_dev *pdev = tp->pci_dev;
  
 +      RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
 +
        rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x080002, ERIAR_EXGMAC);
        rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x38, ERIAR_EXGMAC);
        rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x48, ERIAR_EXGMAC);
  
        rtl_w1w0_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC);
        rtl_w1w0_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC);
 +      rtl_eri_write(tp, 0x2f8, ERIAR_MASK_0011, 0x1d8f, ERIAR_EXGMAC);
  
        RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
        RTL_W32(MISC, RTL_R32(MISC) & ~RXDV_GATED_EN);
        /* Adjust EEE LED frequency */
        RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07);
  
 -      rtl_w1w0_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x02, ERIAR_EXGMAC);
 +      rtl_w1w0_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC);
 +      rtl_w1w0_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC);
 +}
 +
 +static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
 +{
 +      void __iomem *ioaddr = tp->mmio_addr;
 +      static const struct ephy_info e_info_8168g_2[] = {
 +              { 0x00, 0x0000, 0x0008 },
 +              { 0x0c, 0x3df0, 0x0200 },
 +              { 0x19, 0xffff, 0xfc00 },
 +              { 0x1e, 0xffff, 0x20eb }
 +      };
 +
 +      rtl_hw_start_8168g_1(tp);
 +
 +      /* disable aspm and clock request before access ephy */
 +      RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn);
 +      RTL_W8(Config5, RTL_R8(Config5) & ~ASPM_en);
 +      rtl_ephy_init(tp, e_info_8168g_2, ARRAY_SIZE(e_info_8168g_2));
  }
  
  static void rtl_hw_start_8168(struct net_device *dev)
  
        rtl_set_rx_tx_desc_registers(tp, ioaddr);
  
 -      rtl_set_rx_mode(dev);
 -
 -      RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) |
 -              (InterFrameGap << TxInterFrameGapShift));
 +      rtl_set_rx_tx_config_registers(tp);
  
        RTL_R8(IntrMask);
  
        case RTL_GIGA_MAC_VER_41:
                rtl_hw_start_8168g_1(tp);
                break;
 +      case RTL_GIGA_MAC_VER_42:
 +              rtl_hw_start_8168g_2(tp);
 +              break;
  
        default:
                printk(KERN_ERR PFX "%s: unknown chipset (mac_version = %d).\n",
                break;
        }
  
 +      RTL_W8(Cfg9346, Cfg9346_Lock);
 +
        RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
  
 -      RTL_W8(Cfg9346, Cfg9346_Lock);
 +      rtl_set_rx_mode(dev);
  
        RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
  }
@@@ -5506,17 -5424,6 +5528,17 @@@ static void rtl_hw_start_8101(struct ne
  
        RTL_W8(Cfg9346, Cfg9346_Unlock);
  
 +      RTL_W8(MaxTxPacketSize, TxPacketMax);
 +
 +      rtl_set_rx_max_size(ioaddr, rx_buf_sz);
 +
 +      tp->cp_cmd &= ~R810X_CPCMD_QUIRK_MASK;
 +      RTL_W16(CPlusCmd, tp->cp_cmd);
 +
 +      rtl_set_rx_tx_desc_registers(tp, ioaddr);
 +
 +      rtl_set_rx_tx_config_registers(tp);
 +
        switch (tp->mac_version) {
        case RTL_GIGA_MAC_VER_07:
                rtl_hw_start_8102e_1(tp);
        case RTL_GIGA_MAC_VER_39:
                rtl_hw_start_8106(tp);
                break;
 +      case RTL_GIGA_MAC_VER_43:
 +              rtl_hw_start_8168g_2(tp);
 +              break;
        }
  
        RTL_W8(Cfg9346, Cfg9346_Lock);
  
 -      RTL_W8(MaxTxPacketSize, TxPacketMax);
 -
 -      rtl_set_rx_max_size(ioaddr, rx_buf_sz);
 -
 -      tp->cp_cmd &= ~R810X_CPCMD_QUIRK_MASK;
 -      RTL_W16(CPlusCmd, tp->cp_cmd);
 -
        RTL_W16(IntrMitigate, 0x0000);
  
 -      rtl_set_rx_tx_desc_registers(tp, ioaddr);
 -
        RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
 -      rtl_set_rx_tx_config_registers(tp);
 -
 -      RTL_R8(IntrMask);
  
        rtl_set_rx_mode(dev);
  
 +      RTL_R8(IntrMask);
 +
        RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000);
  }
  
@@@ -6830,8 -6744,6 +6852,8 @@@ static void rtl_hw_initialize(struct rt
        switch (tp->mac_version) {
        case RTL_GIGA_MAC_VER_40:
        case RTL_GIGA_MAC_VER_41:
 +      case RTL_GIGA_MAC_VER_42:
 +      case RTL_GIGA_MAC_VER_43:
                rtl_hw_init_8168g(tp);
                break;
  
index cc1e0c1a6f48665ee2edf9233fd8041337163c34,d1a670d7b10cfd05f28c07624616f436ebf6c321..70b7f68c4958b76b854d34559535ec27b510f791
@@@ -19,7 -19,7 +19,7 @@@
   * USA
   *
   * The full GNU General Public License is included in this distribution
 - * in the file called LICENSE.GPL.
 + * in the file called COPYING.
   *
   * Contact Information:
   *  Intel Linux Wireless <ilw@linux.intel.com>
@@@ -418,8 -418,7 +418,8 @@@ int iwlagn_tx_skb(struct iwl_priv *priv
                                " Tx flags = 0x%08x, agg.state = %d",
                                info->flags, tid_data->agg.state);
                        IWL_ERR(priv, "sta_id = %d, tid = %d seq_num = %d",
 -                              sta_id, tid, SEQ_TO_SN(tid_data->seq_number));
 +                              sta_id, tid,
 +                              IEEE80211_SEQ_TO_SN(tid_data->seq_number));
                        goto drop_unlock_sta;
                }
  
@@@ -570,7 -569,7 +570,7 @@@ int iwlagn_tx_agg_stop(struct iwl_priv 
                return 0;
        }
  
 -      tid_data->agg.ssn = SEQ_TO_SN(tid_data->seq_number);
 +      tid_data->agg.ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number);
  
        /* There are still packets for this RA / TID in the HW */
        if (!test_bit(txq_id, priv->agg_q_alloc)) {
@@@ -652,7 -651,7 +652,7 @@@ int iwlagn_tx_agg_start(struct iwl_pri
  
        spin_lock_bh(&priv->sta_lock);
        tid_data = &priv->tid_data[sta_id][tid];
 -      tid_data->agg.ssn = SEQ_TO_SN(tid_data->seq_number);
 +      tid_data->agg.ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number);
        tid_data->agg.txq_id = txq_id;
  
        *ssn = tid_data->agg.ssn;
@@@ -912,7 -911,7 +912,7 @@@ static void iwlagn_count_agg_tx_err_sta
  static inline u32 iwlagn_get_scd_ssn(struct iwlagn_tx_resp *tx_resp)
  {
        return le32_to_cpup((__le32 *)&tx_resp->status +
 -                          tx_resp->frame_count) & MAX_SN;
 +                          tx_resp->frame_count) & IEEE80211_MAX_SN;
  }
  
  static void iwl_rx_reply_tx_agg(struct iwl_priv *priv,
@@@ -1149,7 -1148,7 +1149,7 @@@ int iwlagn_rx_reply_tx(struct iwl_priv 
  
        if (tx_resp->frame_count == 1) {
                u16 next_reclaimed = le16_to_cpu(tx_resp->seq_ctl);
 -              next_reclaimed = SEQ_TO_SN(next_reclaimed + 0x10);
 +              next_reclaimed = IEEE80211_SEQ_TO_SN(next_reclaimed + 0x10);
  
                if (is_agg) {
                        /* If this is an aggregation queue, we can rely on the
                        memset(&info->status, 0, sizeof(info->status));
  
                        if (status == TX_STATUS_FAIL_PASSIVE_NO_RX &&
-                           iwl_is_associated_ctx(ctx) && ctx->vif &&
+                           ctx->vif &&
                            ctx->vif->type == NL80211_IFTYPE_STATION) {
                                /* block and stop all queues */
                                priv->passive_no_rx = true;
index dbf5b1289516b0193a4e6a3bcba49efac5fc450a,8aaf56ade4d9d086f36b7dee9d880f7628b50b23..78c2bb8d3726327c569036817dfbdd82ad134562
@@@ -1892,7 -1892,8 +1892,8 @@@ mwifiex_cfg80211_scan(struct wiphy *wip
                }
        }
  
-       for (i = 0; i < request->n_channels; i++) {
+       for (i = 0; i < min_t(u32, request->n_channels,
+                             MWIFIEX_USER_SCAN_CHAN_MAX); i++) {
                chan = request->channels[i];
                priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
                priv->user_scan_cfg->chan_list[i].radio_type = chan->band;
@@@ -1932,10 -1933,66 +1933,10 @@@ static void mwifiex_setup_vht_caps(stru
                                   struct mwifiex_private *priv)
  {
        struct mwifiex_adapter *adapter = priv->adapter;
 -      u32 vht_cap = 0, cap = adapter->hw_dot_11ac_dev_cap;
  
        vht_info->vht_supported = true;
  
 -      switch (GET_VHTCAP_MAXMPDULEN(cap)) {
 -      case 0x00:
 -              vht_cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895;
 -              break;
 -      case 0x01:
 -              vht_cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991;
 -              break;
 -      case 0x10:
 -              vht_cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454;
 -          break;
 -      default:
 -          dev_err(adapter->dev, "unsupported MAX MPDU len\n");
 -          break;
 -      }
 -
 -      if (ISSUPP_11ACVHTHTCVHT(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_HTC_VHT;
 -
 -      if (ISSUPP_11ACVHTTXOPPS(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS;
 -
 -      if (ISSUPP_11ACMURXBEAMFORMEE(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
 -
 -      if (ISSUPP_11ACMUTXBEAMFORMEE(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
 -
 -      if (ISSUPP_11ACSUBEAMFORMER(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
 -
 -      if (ISSUPP_11ACSUBEAMFORMEE(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
 -
 -      if (ISSUPP_11ACRXSTBC(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_RXSTBC_1;
 -
 -      if (ISSUPP_11ACTXSTBC(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_TXSTBC;
 -
 -      if (ISSUPP_11ACSGI160(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_SHORT_GI_160;
 -
 -      if (ISSUPP_11ACSGI80(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_SHORT_GI_80;
 -
 -      if (ISSUPP_11ACLDPC(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_RXLDPC;
 -
 -      if (ISSUPP_11ACBW8080(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
 -
 -      if (ISSUPP_11ACBW160(cap))
 -              vht_cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
 -
 -      vht_info->cap = vht_cap;
 -
 +      vht_info->cap = adapter->hw_dot_11ac_dev_cap;
        /* Update MCS support for VHT */
        vht_info->vht_mcs.rx_mcs_map = cpu_to_le16(
                                adapter->hw_dot_11ac_mcs_support & 0xFFFF);
@@@ -2179,7 -2236,6 +2180,7 @@@ struct wireless_dev *mwifiex_add_virtua
        dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
        dev->watchdog_timeo = MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT;
        dev->hard_header_len += MWIFIEX_MIN_DATA_HEADER_LEN;
 +      dev->ethtool_ops = &mwifiex_ethtool_ops;
  
        mdev_priv = netdev_priv(dev);
        *((unsigned long *) mdev_priv) = (unsigned long) priv;
@@@ -2238,152 -2294,6 +2239,152 @@@ int mwifiex_del_virtual_intf(struct wip
  }
  EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf);
  
 +#ifdef CONFIG_PM
 +static bool
 +mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
 +                           s8 *byte_seq)
 +{
 +      int j, k, valid_byte_cnt = 0;
 +      bool dont_care_byte = false;
 +
 +      for (j = 0; j < DIV_ROUND_UP(pat->pattern_len, 8); j++) {
 +              for (k = 0; k < 8; k++) {
 +                      if (pat->mask[j] & 1 << k) {
 +                              memcpy(byte_seq + valid_byte_cnt,
 +                                     &pat->pattern[j * 8 + k], 1);
 +                              valid_byte_cnt++;
 +                              if (dont_care_byte)
 +                                      return false;
 +                      } else {
 +                              if (valid_byte_cnt)
 +                                      dont_care_byte = true;
 +                      }
 +
 +                      if (valid_byte_cnt > MAX_BYTESEQ)
 +                              return false;
 +              }
 +      }
 +
 +      byte_seq[MAX_BYTESEQ] = valid_byte_cnt;
 +
 +      return true;
 +}
 +
 +static int mwifiex_cfg80211_suspend(struct wiphy *wiphy,
 +                                  struct cfg80211_wowlan *wowlan)
 +{
 +      struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
 +      struct mwifiex_ds_mef_cfg mef_cfg;
 +      struct mwifiex_mef_entry *mef_entry;
 +      int i, filt_num = 0, ret;
 +      bool first_pat = true;
 +      u8 byte_seq[MAX_BYTESEQ + 1];
 +      const u8 ipv4_mc_mac[] = {0x33, 0x33};
 +      const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e};
 +      struct mwifiex_private *priv =
 +                      mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA);
 +
 +      if (!wowlan) {
 +              dev_warn(adapter->dev, "None of the WOWLAN triggers enabled\n");
 +              return 0;
 +      }
 +
 +      if (!priv->media_connected) {
 +              dev_warn(adapter->dev,
 +                       "Can not configure WOWLAN in disconnected state\n");
 +              return 0;
 +      }
 +
 +      mef_entry = kzalloc(sizeof(*mef_entry), GFP_KERNEL);
 +      if (!mef_entry)
 +              return -ENOMEM;
 +
 +      memset(&mef_cfg, 0, sizeof(mef_cfg));
 +      mef_cfg.num_entries = 1;
 +      mef_cfg.mef_entry = mef_entry;
 +      mef_entry->mode = MEF_MODE_HOST_SLEEP;
 +      mef_entry->action = MEF_ACTION_ALLOW_AND_WAKEUP_HOST;
 +
 +      for (i = 0; i < wowlan->n_patterns; i++) {
 +              memset(byte_seq, 0, sizeof(byte_seq));
 +              if (!mwifiex_is_pattern_supported(&wowlan->patterns[i],
 +                                                byte_seq)) {
 +                      wiphy_err(wiphy, "Pattern not supported\n");
 +                      kfree(mef_entry);
 +                      return -EOPNOTSUPP;
 +              }
 +
 +              if (!wowlan->patterns[i].pkt_offset) {
 +                      if (!(byte_seq[0] & 0x01) &&
 +                          (byte_seq[MAX_BYTESEQ] == 1)) {
 +                              mef_cfg.criteria |= MWIFIEX_CRITERIA_UNICAST;
 +                              continue;
 +                      } else if (is_broadcast_ether_addr(byte_seq)) {
 +                              mef_cfg.criteria |= MWIFIEX_CRITERIA_BROADCAST;
 +                              continue;
 +                      } else if ((!memcmp(byte_seq, ipv4_mc_mac, 2) &&
 +                                  (byte_seq[MAX_BYTESEQ] == 2)) ||
 +                                 (!memcmp(byte_seq, ipv6_mc_mac, 3) &&
 +                                  (byte_seq[MAX_BYTESEQ] == 3))) {
 +                              mef_cfg.criteria |= MWIFIEX_CRITERIA_MULTICAST;
 +                              continue;
 +                      }
 +              }
 +
 +              mef_entry->filter[filt_num].repeat = 1;
 +              mef_entry->filter[filt_num].offset =
 +                                              wowlan->patterns[i].pkt_offset;
 +              memcpy(mef_entry->filter[filt_num].byte_seq, byte_seq,
 +                     sizeof(byte_seq));
 +              mef_entry->filter[filt_num].filt_type = TYPE_EQ;
 +
 +              if (first_pat)
 +                      first_pat = false;
 +              else
 +                      mef_entry->filter[filt_num].filt_action = TYPE_AND;
 +
 +              filt_num++;
 +      }
 +
 +      if (wowlan->magic_pkt) {
 +              mef_cfg.criteria |= MWIFIEX_CRITERIA_UNICAST;
 +              mef_entry->filter[filt_num].repeat = 16;
 +              memcpy(mef_entry->filter[filt_num].byte_seq, priv->curr_addr,
 +                     ETH_ALEN);
 +              mef_entry->filter[filt_num].byte_seq[MAX_BYTESEQ] = ETH_ALEN;
 +              mef_entry->filter[filt_num].offset = 14;
 +              mef_entry->filter[filt_num].filt_type = TYPE_EQ;
 +              if (filt_num)
 +                      mef_entry->filter[filt_num].filt_action = TYPE_OR;
 +      }
 +
 +      if (!mef_cfg.criteria)
 +              mef_cfg.criteria = MWIFIEX_CRITERIA_BROADCAST |
 +                                 MWIFIEX_CRITERIA_UNICAST |
 +                                 MWIFIEX_CRITERIA_MULTICAST;
 +
 +      ret =  mwifiex_send_cmd_sync(priv, HostCmd_CMD_MEF_CFG,
 +                                   HostCmd_ACT_GEN_SET, 0,
 +                                   &mef_cfg);
 +
 +      kfree(mef_entry);
 +      return ret;
 +}
 +
 +static int mwifiex_cfg80211_resume(struct wiphy *wiphy)
 +{
 +      return 0;
 +}
 +
 +static void mwifiex_cfg80211_set_wakeup(struct wiphy *wiphy,
 +                                     bool enabled)
 +{
 +      struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
 +
 +      device_set_wakeup_enable(adapter->dev, enabled);
 +}
 +#endif
 +
  /* station cfg80211 operations */
  static struct cfg80211_ops mwifiex_cfg80211_ops = {
        .add_virtual_intf = mwifiex_add_virtual_intf,
        .change_beacon = mwifiex_cfg80211_change_beacon,
        .set_cqm_rssi_config = mwifiex_cfg80211_set_cqm_rssi_config,
        .set_antenna = mwifiex_cfg80211_set_antenna,
 +#ifdef CONFIG_PM
 +      .suspend = mwifiex_cfg80211_suspend,
 +      .resume = mwifiex_cfg80211_resume,
 +      .set_wakeup = mwifiex_cfg80211_set_wakeup,
 +#endif
  };
  
  /*
@@@ -2475,14 -2380,6 +2476,14 @@@ int mwifiex_register_cfg80211(struct mw
  
        wiphy_apply_custom_regulatory(wiphy, &mwifiex_world_regdom_custom);
  
 +#ifdef CONFIG_PM
 +      wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT;
 +      wiphy->wowlan.n_patterns = MWIFIEX_MAX_FILTERS;
 +      wiphy->wowlan.pattern_min_len = 1;
 +      wiphy->wowlan.pattern_max_len = MWIFIEX_MAX_PATTERN_LEN;
 +      wiphy->wowlan.max_pkt_offset = MWIFIEX_MAX_OFFSET_LEN;
 +#endif
 +
        wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
                                    NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
                                    NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
index a302f7f01f868003bd48ee8b7bc5c213f215f7d9,6151e903eef0a4a380ca03cb24f26e5121543758..53d3939358a7c7f680e23cbe35c8454483a949a5
@@@ -144,6 -144,8 +144,6 @@@ static inline bool dev_xmit_complete(in
  # else
  #  define LL_MAX_HEADER 96
  # endif
 -#elif IS_ENABLED(CONFIG_TR)
 -# define LL_MAX_HEADER 48
  #else
  # define LL_MAX_HEADER 32
  #endif
@@@ -208,9 -210,9 +208,9 @@@ struct netdev_hw_addr 
  #define NETDEV_HW_ADDR_T_SLAVE                3
  #define NETDEV_HW_ADDR_T_UNICAST      4
  #define NETDEV_HW_ADDR_T_MULTICAST    5
-       bool                    synced;
        bool                    global_use;
        int                     refcount;
+       int                     synced;
        struct rcu_head         rcu_head;
  };
  
@@@ -1071,8 -1073,6 +1071,8 @@@ struct net_device 
        struct list_head        dev_list;
        struct list_head        napi_list;
        struct list_head        unreg_list;
 +      struct list_head        upper_dev_list; /* List of upper devices */
 +
  
        /* currently active device features */
        netdev_features_t       features;
        spinlock_t              addr_list_lock;
        struct netdev_hw_addr_list      uc;     /* Unicast mac addresses */
        struct netdev_hw_addr_list      mc;     /* Multicast mac addresses */
 +      struct netdev_hw_addr_list      dev_addrs; /* list of device
 +                                                  * hw addresses
 +                                                  */
 +#ifdef CONFIG_SYSFS
 +      struct kset             *queues_kset;
 +#endif
 +
        bool                    uc_promisc;
        unsigned int            promiscuity;
        unsigned int            allmulti;
                                                 * avoid dirtying this cache line.
                                                 */
  
 -      struct list_head        upper_dev_list; /* List of upper devices */
 -
        /* Interface address info used in eth_type_trans() */
        unsigned char           *dev_addr;      /* hw address, (before bcast
                                                   because most packets are
                                                   unicast) */
  
 -      struct netdev_hw_addr_list      dev_addrs; /* list of device
 -                                                    hw addresses */
 -
 -      unsigned char           broadcast[MAX_ADDR_LEN];        /* hw bcast add */
 -
 -#ifdef CONFIG_SYSFS
 -      struct kset             *queues_kset;
 -#endif
  
  #ifdef CONFIG_RPS
        struct netdev_rx_queue  *_rx;
        /* Number of RX queues currently active in device */
        unsigned int            real_num_rx_queues;
  
 -#ifdef CONFIG_RFS_ACCEL
 -      /* CPU reverse-mapping for RX completion interrupts, indexed
 -       * by RX queue number.  Assigned by driver.  This must only be
 -       * set if the ndo_rx_flow_steer operation is defined. */
 -      struct cpu_rmap         *rx_cpu_rmap;
 -#endif
  #endif
  
        rx_handler_func_t __rcu *rx_handler;
        void __rcu              *rx_handler_data;
  
        struct netdev_queue __rcu *ingress_queue;
 +      unsigned char           broadcast[MAX_ADDR_LEN];        /* hw bcast add */
 +
  
  /*
   * Cache lines mostly used on transmit path
  #ifdef CONFIG_XPS
        struct xps_dev_maps __rcu *xps_maps;
  #endif
 +#ifdef CONFIG_RFS_ACCEL
 +      /* CPU reverse-mapping for RX completion interrupts, indexed
 +       * by RX queue number.  Assigned by driver.  This must only be
 +       * set if the ndo_rx_flow_steer operation is defined. */
 +      struct cpu_rmap         *rx_cpu_rmap;
 +#endif
  
        /* These may be needed for future network-power-down code. */
  
@@@ -1474,11 -1475,6 +1474,11 @@@ static inline void *netdev_priv(const s
   */
  #define SET_NETDEV_DEVTYPE(net, devtype)      ((net)->dev.type = (devtype))
  
 +/* Default NAPI poll() weight
 + * Device drivers are strongly advised to not use bigger value
 + */
 +#define NAPI_POLL_WEIGHT 64
 +
  /**
   *    netif_napi_add - initialize a napi context
   *    @dev:  network device
@@@ -1616,9 -1612,6 +1616,9 @@@ extern seqcount_t       devnet_rename_seq;      /
                list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list)
  #define for_each_netdev_continue_rcu(net, d)          \
        list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
 +#define for_each_netdev_in_bond_rcu(bond, slave)      \
 +              for_each_netdev_rcu(&init_net, slave)   \
 +                      if (netdev_master_upper_dev_get_rcu(slave) == bond)
  #define net_device_entry(lh)  list_entry(lh, struct net_device, dev_list)
  
  static inline struct net_device *next_net_device(struct net_device *dev)
@@@ -1691,6 -1684,7 +1691,6 @@@ extern int              netdev_refcnt_read(const s
  extern void           free_netdev(struct net_device *dev);
  extern void           synchronize_net(void);
  extern int            init_dummy_netdev(struct net_device *dev);
 -extern void           netdev_resync_ops(struct net_device *dev);
  
  extern struct net_device      *dev_get_by_index(struct net *net, int ifindex);
  extern struct net_device      *__dev_get_by_index(struct net *net, int ifindex);
@@@ -2684,19 -2678,6 +2684,19 @@@ struct sk_buff *skb_gso_segment(struct 
  {
        return __skb_gso_segment(skb, features, true);
  }
 +__be16 skb_network_protocol(struct sk_buff *skb);
 +
 +static inline bool can_checksum_protocol(netdev_features_t features,
 +                                       __be16 protocol)
 +{
 +      return ((features & NETIF_F_GEN_CSUM) ||
 +              ((features & NETIF_F_V4_CSUM) &&
 +               protocol == htons(ETH_P_IP)) ||
 +              ((features & NETIF_F_V6_CSUM) &&
 +               protocol == htons(ETH_P_IPV6)) ||
 +              ((features & NETIF_F_FCOE_CRC) &&
 +               protocol == htons(ETH_P_FCOE)));
 +}
  
  #ifdef CONFIG_BUG
  extern void netdev_rx_csum_fault(struct net_device *dev);
@@@ -2775,11 -2756,6 +2775,11 @@@ static inline void netif_set_gso_max_si
        dev->gso_max_size = size;
  }
  
 +static inline bool netif_is_bond_master(struct net_device *dev)
 +{
 +      return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
 +}
 +
  static inline bool netif_is_bond_slave(struct net_device *dev)
  {
        return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
diff --combined include/linux/skbuff.h
index 364e2440a7ee293c32efbba00feaeb7d7548ef54,b8292d8cc9fa6238ed0691194f714f827cabd058..e27d1c782f32aa079aa92c32f0d523e46ba5af98
@@@ -32,7 -32,6 +32,7 @@@
  #include <linux/hrtimer.h>
  #include <linux/dma-mapping.h>
  #include <linux/netdev_features.h>
 +#include <net/flow_keys.h>
  
  /* Don't change this without changing skb_csum_unnecessary! */
  #define CHECKSUM_NONE 0
@@@ -317,8 -316,6 +317,8 @@@ enum 
        SKB_GSO_FCOE = 1 << 5,
  
        SKB_GSO_GRE = 1 << 6,
 +
 +      SKB_GSO_UDP_TUNNEL = 1 << 7,
  };
  
  #if BITS_PER_LONG > 32
@@@ -390,7 -387,6 +390,7 @@@ typedef unsigned char *sk_buff_data_t
   *    @vlan_tci: vlan tag control information
   *    @inner_transport_header: Inner transport layer header (encapsulation)
   *    @inner_network_header: Network layer header (encapsulation)
 + *    @inner_mac_header: Link layer header (encapsulation)
   *    @transport_header: Transport layer header
   *    @network_header: Network layer header
   *    @mac_header: Link layer header
@@@ -509,7 -505,6 +509,7 @@@ struct sk_buff 
  
        sk_buff_data_t          inner_transport_header;
        sk_buff_data_t          inner_network_header;
 +      sk_buff_data_t          inner_mac_header;
        sk_buff_data_t          transport_header;
        sk_buff_data_t          network_header;
        sk_buff_data_t          mac_header;
@@@ -575,40 -570,7 +575,40 @@@ static inline void skb_dst_set(struct s
        skb->_skb_refdst = (unsigned long)dst;
  }
  
 -extern void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst);
 +extern void __skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst,
 +                              bool force);
 +
 +/**
 + * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
 + * @skb: buffer
 + * @dst: dst entry
 + *
 + * Sets skb dst, assuming a reference was not taken on dst.
 + * If dst entry is cached, we do not take reference and dst_release
 + * will be avoided by refdst_drop. If dst entry is not cached, we take
 + * reference, so that last dst_release can destroy the dst immediately.
 + */
 +static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst)
 +{
 +      __skb_dst_set_noref(skb, dst, false);
 +}
 +
 +/**
 + * skb_dst_set_noref_force - sets skb dst, without taking reference
 + * @skb: buffer
 + * @dst: dst entry
 + *
 + * Sets skb dst, assuming a reference was not taken on dst.
 + * No reference is taken and no dst_release will be called. While for
 + * cached dsts deferred reclaim is a basic feature, for entries that are
 + * not cached it is caller's job to guarantee that last dst_release for
 + * provided dst happens when nobody uses it, eg. after a RCU grace period.
 + */
 +static inline void skb_dst_set_noref_force(struct sk_buff *skb,
 +                                         struct dst_entry *dst)
 +{
 +      __skb_dst_set_noref(skb, dst, true);
 +}
  
  /**
   * skb_dst_is_noref - Test if skb dst isn't refcounted
@@@ -1509,7 -1471,6 +1509,7 @@@ static inline void skb_reserve(struct s
  
  static inline void skb_reset_inner_headers(struct sk_buff *skb)
  {
 +      skb->inner_mac_header = skb->mac_header;
        skb->inner_network_header = skb->network_header;
        skb->inner_transport_header = skb->transport_header;
  }
@@@ -1555,22 -1516,6 +1555,22 @@@ static inline void skb_set_inner_networ
        skb->inner_network_header += offset;
  }
  
 +static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
 +{
 +      return skb->head + skb->inner_mac_header;
 +}
 +
 +static inline void skb_reset_inner_mac_header(struct sk_buff *skb)
 +{
 +      skb->inner_mac_header = skb->data - skb->head;
 +}
 +
 +static inline void skb_set_inner_mac_header(struct sk_buff *skb,
 +                                          const int offset)
 +{
 +      skb_reset_inner_mac_header(skb);
 +      skb->inner_mac_header += offset;
 +}
  static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
  {
        return skb->transport_header != ~0U;
@@@ -1664,21 -1609,6 +1664,21 @@@ static inline void skb_set_inner_networ
        skb->inner_network_header = skb->data + offset;
  }
  
 +static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
 +{
 +      return skb->inner_mac_header;
 +}
 +
 +static inline void skb_reset_inner_mac_header(struct sk_buff *skb)
 +{
 +      skb->inner_mac_header = skb->data;
 +}
 +
 +static inline void skb_set_inner_mac_header(struct sk_buff *skb,
 +                                              const int offset)
 +{
 +      skb->inner_mac_header = skb->data + offset;
 +}
  static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
  {
        return skb->transport_header != NULL;
@@@ -1736,19 -1666,6 +1736,19 @@@ static inline void skb_set_mac_header(s
  }
  #endif /* NET_SKBUFF_DATA_USES_OFFSET */
  
 +static inline void skb_probe_transport_header(struct sk_buff *skb,
 +                                            const int offset_hint)
 +{
 +      struct flow_keys keys;
 +
 +      if (skb_transport_header_was_set(skb))
 +              return;
 +      else if (skb_flow_dissect(skb, &keys))
 +              skb_set_transport_header(skb, keys.thoff);
 +      else
 +              skb_set_transport_header(skb, offset_hint);
 +}
 +
  static inline void skb_mac_header_rebuild(struct sk_buff *skb)
  {
        if (skb_mac_header_was_set(skb)) {
@@@ -2726,6 -2643,13 +2726,13 @@@ static inline void nf_reset(struct sk_b
  #endif
  }
  
+ static inline void nf_reset_trace(struct sk_buff *skb)
+ {
+ #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
+       skb->nf_trace = 0;
+ #endif
+ }
  /* Note: This doesn't put any conntrack and bridge info in dst. */
  static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
  {
@@@ -2887,8 -2811,6 +2894,8 @@@ static inline void skb_checksum_none_as
  
  bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
  
 +u32 __skb_get_poff(const struct sk_buff *skb);
 +
  /**
   * skb_head_is_locked - Determine if the skb->head is locked down
   * @skb: skb to check
index fea778e1dc27dc104885378a80c850afff75b11d,0d1b08cc76e1d73acba966e4c22f64c0285cce05..d5a973bf8a6f1966a91582616e76cf3a2adce440
@@@ -230,6 -230,8 +230,8 @@@ int bt_sock_recvmsg(struct kiocb *iocb
        if (flags & (MSG_OOB))
                return -EOPNOTSUPP;
  
+       msg->msg_namelen = 0;
        skb = skb_recv_datagram(sk, flags, noblock, &err);
        if (!skb) {
                if (sk->sk_shutdown & RCV_SHUTDOWN)
                return err;
        }
  
-       msg->msg_namelen = 0;
        copied = skb->len;
        if (len < copied) {
                msg->msg_flags |= MSG_TRUNC;
@@@ -422,8 -422,7 +422,8 @@@ unsigned int bt_sock_poll(struct file *
                return bt_accept_poll(sk);
  
        if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 -              mask |= POLLERR;
 +              mask |= POLLERR |
 +                      (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
  
        if (sk->sk_shutdown & RCV_SHUTDOWN)
                mask |= POLLRDHUP | POLLIN | POLLRDNORM;
diff --combined net/caif/caif_socket.c
index 1d337e02bc6319066ab764991316f43388037d1e,ff2ff3ce6965a73dcf74918cd5c5bcc1b4a7d51b..630b8be6e748d92fd48a4dc6fb82db303d57a636
@@@ -197,8 -197,8 +197,8 @@@ static void cfsk_put(struct cflayer *la
  
  /* Packet Control Callback function called from CAIF */
  static void caif_ctrl_cb(struct cflayer *layr,
 -                              enum caif_ctrlcmd flow,
 -                              int phyid)
 +                       enum caif_ctrlcmd flow,
 +                       int phyid)
  {
        struct caifsock *cf_sk = container_of(layr, struct caifsock, layer);
        switch (flow) {
@@@ -274,7 -274,7 +274,7 @@@ static void caif_check_flow_release(str
   * changed locking, address handling and added MSG_TRUNC.
   */
  static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,
 -                              struct msghdr *m, size_t len, int flags)
 +                             struct msghdr *m, size_t len, int flags)
  
  {
        struct sock *sk = sock->sk;
        if (m->msg_flags&MSG_OOB)
                goto read_error;
  
+       m->msg_namelen = 0;
        skb = skb_recv_datagram(sk, flags, 0 , &ret);
        if (!skb)
                goto read_error;
@@@ -346,8 -348,8 +348,8 @@@ static long caif_stream_data_wait(struc
   * changed locking calls, changed address handling.
   */
  static int caif_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 -                              struct msghdr *msg, size_t size,
 -                              int flags)
 +                             struct msghdr *msg, size_t size,
 +                             int flags)
  {
        struct sock *sk = sock->sk;
        int copied = 0;
@@@ -462,7 -464,7 +464,7 @@@ out
   * CAIF flow-on and sock_writable.
   */
  static long caif_wait_for_flow_on(struct caifsock *cf_sk,
 -                              int wait_writeable, long timeo, int *err)
 +                                int wait_writeable, long timeo, int *err)
  {
        struct sock *sk = &cf_sk->sk;
        DEFINE_WAIT(wait);
@@@ -516,7 -518,7 +518,7 @@@ static int transmit_skb(struct sk_buff 
  
  /* Copied from af_unix:unix_dgram_sendmsg, and adapted to CAIF */
  static int caif_seqpkt_sendmsg(struct kiocb *kiocb, struct socket *sock,
 -                      struct msghdr *msg, size_t len)
 +                             struct msghdr *msg, size_t len)
  {
        struct sock *sk = sock->sk;
        struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
@@@ -591,7 -593,7 +593,7 @@@ err
   * and other minor adaptations.
   */
  static int caif_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
 -                              struct msghdr *msg, size_t len)
 +                             struct msghdr *msg, size_t len)
  {
        struct sock *sk = sock->sk;
        struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
@@@ -670,7 -672,7 +672,7 @@@ out_err
  }
  
  static int setsockopt(struct socket *sock,
 -                      int lvl, int opt, char __user *ov, unsigned int ol)
 +                    int lvl, int opt, char __user *ov, unsigned int ol)
  {
        struct sock *sk = sock->sk;
        struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
@@@ -932,7 -934,7 +934,7 @@@ static int caif_release(struct socket *
  
  /* Copied from af_unix.c:unix_poll(), added CAIF tx_flow handling */
  static unsigned int caif_poll(struct file *file,
 -                              struct socket *sock, poll_table *wait)
 +                            struct socket *sock, poll_table *wait)
  {
        struct sock *sk = sock->sk;
        unsigned int mask;
@@@ -1022,7 -1024,7 +1024,7 @@@ static void caif_sock_destructor(struc
  }
  
  static int caif_create(struct net *net, struct socket *sock, int protocol,
 -                      int kern)
 +                     int kern)
  {
        struct sock *sk = NULL;
        struct caifsock *cf_sk = NULL;
diff --combined net/core/dev.c
index 63e25332924d34d7791090f1164c5d129a5a7009,e7d68ed8aafe60f75233fcdc1ed68c39e755cda6..3655ff9273151836f4a94233f0a7613174a9c57d
@@@ -1639,6 -1639,7 +1639,7 @@@ int dev_forward_skb(struct net_device *
        skb->mark = 0;
        secpath_reset(skb);
        nf_reset(skb);
+       nf_reset_trace(skb);
        return netif_rx(skb);
  }
  EXPORT_SYMBOL_GPL(dev_forward_skb);
@@@ -2206,8 -2207,16 +2207,8 @@@ out
  }
  EXPORT_SYMBOL(skb_checksum_help);
  
 -/**
 - *    skb_mac_gso_segment - mac layer segmentation handler.
 - *    @skb: buffer to segment
 - *    @features: features for the output path (see dev->features)
 - */
 -struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
 -                                  netdev_features_t features)
 +__be16 skb_network_protocol(struct sk_buff *skb)
  {
 -      struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
 -      struct packet_offload *ptype;
        __be16 type = skb->protocol;
        int vlan_depth = ETH_HLEN;
  
                struct vlan_hdr *vh;
  
                if (unlikely(!pskb_may_pull(skb, vlan_depth + VLAN_HLEN)))
 -                      return ERR_PTR(-EINVAL);
 +                      return 0;
  
                vh = (struct vlan_hdr *)(skb->data + vlan_depth);
                type = vh->h_vlan_encapsulated_proto;
                vlan_depth += VLAN_HLEN;
        }
  
 +      return type;
 +}
 +
 +/**
 + *    skb_mac_gso_segment - mac layer segmentation handler.
 + *    @skb: buffer to segment
 + *    @features: features for the output path (see dev->features)
 + */
 +struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
 +                                  netdev_features_t features)
 +{
 +      struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
 +      struct packet_offload *ptype;
 +      __be16 type = skb_network_protocol(skb);
 +
 +      if (unlikely(!type))
 +              return ERR_PTR(-EINVAL);
 +
        __skb_pull(skb, skb->mac_len);
  
        rcu_read_lock();
@@@ -2406,12 -2397,24 +2407,12 @@@ static int dev_gso_segment(struct sk_bu
        return 0;
  }
  
 -static bool can_checksum_protocol(netdev_features_t features, __be16 protocol)
 -{
 -      return ((features & NETIF_F_GEN_CSUM) ||
 -              ((features & NETIF_F_V4_CSUM) &&
 -               protocol == htons(ETH_P_IP)) ||
 -              ((features & NETIF_F_V6_CSUM) &&
 -               protocol == htons(ETH_P_IPV6)) ||
 -              ((features & NETIF_F_FCOE_CRC) &&
 -               protocol == htons(ETH_P_FCOE)));
 -}
 -
  static netdev_features_t harmonize_features(struct sk_buff *skb,
        __be16 protocol, netdev_features_t features)
  {
        if (skb->ip_summed != CHECKSUM_NONE &&
            !can_checksum_protocol(features, protocol)) {
                features &= ~NETIF_F_ALL_CSUM;
 -              features &= ~NETIF_F_SG;
        } else if (illegal_highdma(skb->dev, skb)) {
                features &= ~NETIF_F_SG;
        }
@@@ -2586,7 -2589,6 +2587,7 @@@ static void qdisc_pkt_len_init(struct s
         */
        if (shinfo->gso_size)  {
                unsigned int hdr_len;
 +              u16 gso_segs = shinfo->gso_segs;
  
                /* mac layer + network layer */
                hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
                        hdr_len += tcp_hdrlen(skb);
                else
                        hdr_len += sizeof(struct udphdr);
 -              qdisc_skb_cb(skb)->pkt_len += (shinfo->gso_segs - 1) * hdr_len;
 +
 +              if (shinfo->gso_type & SKB_GSO_DODGY)
 +                      gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
 +                                              shinfo->gso_size);
 +
 +              qdisc_skb_cb(skb)->pkt_len += (gso_segs - 1) * hdr_len;
        }
  }
  
@@@ -3329,7 -3326,7 +3330,7 @@@ EXPORT_SYMBOL_GPL(netdev_rx_handler_reg
   *    netdev_rx_handler_unregister - unregister receive handler
   *    @dev: device to unregister a handler from
   *
 - *    Unregister a receive hander from a device.
 + *    Unregister a receive handler from a device.
   *
   *    The caller must hold the rtnl_mutex.
   */
@@@ -4066,9 -4063,6 +4067,9 @@@ void netif_napi_add(struct net_device *
        napi->gro_list = NULL;
        napi->skb = NULL;
        napi->poll = poll;
 +      if (weight > NAPI_POLL_WEIGHT)
 +              pr_err_once("netif_napi_add() called with weight %d on device %s\n",
 +                          weight, dev->name);
        napi->weight = weight;
        list_add(&napi->dev_list, &dev->napi_list);
        napi->dev = dev;
@@@ -4930,25 -4924,20 +4931,25 @@@ static netdev_features_t netdev_fix_fea
                features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
        }
  
 -      /* Fix illegal SG+CSUM combinations. */
 -      if ((features & NETIF_F_SG) &&
 -          !(features & NETIF_F_ALL_CSUM)) {
 -              netdev_dbg(dev,
 -                      "Dropping NETIF_F_SG since no checksum feature.\n");
 -              features &= ~NETIF_F_SG;
 -      }
 -
        /* TSO requires that SG is present as well. */
        if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) {
                netdev_dbg(dev, "Dropping TSO features since no SG feature.\n");
                features &= ~NETIF_F_ALL_TSO;
        }
  
 +      if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 +                                      !(features & NETIF_F_IP_CSUM)) {
 +              netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
 +              features &= ~NETIF_F_TSO;
 +              features &= ~NETIF_F_TSO_ECN;
 +      }
 +
 +      if ((features & NETIF_F_TSO6) && !(features & NETIF_F_HW_CSUM) &&
 +                                       !(features & NETIF_F_IPV6_CSUM)) {
 +              netdev_dbg(dev, "Dropping TSO6 features since no CSUM feature.\n");
 +              features &= ~NETIF_F_TSO6;
 +      }
 +
        /* TSO ECN requires that TSO is present as well. */
        if ((features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN)
                features &= ~NETIF_F_TSO_ECN;
@@@ -5216,10 -5205,6 +5217,10 @@@ int register_netdevice(struct net_devic
         */
        dev->vlan_features |= NETIF_F_HIGHDMA;
  
 +      /* Make NETIF_F_SG inheritable to tunnel devices.
 +       */
 +      dev->hw_enc_features |= NETIF_F_SG;
 +
        ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev);
        ret = notifier_to_errno(ret);
        if (ret)
diff --combined net/ipv4/devinet.c
index 5d985e36753526f4b9cfb37cde3be352556a4b0c,96083b7a436bc9efddd0b8b3473caa78286e5f02..2759dfd576aeb6ee85ad7c17155cc3a9fc924e94
@@@ -536,7 -536,7 +536,7 @@@ struct in_ifaddr *inet_ifa_byprefix(str
        return NULL;
  }
  
 -static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 +static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
  {
        struct net *net = sock_net(skb->sk);
        struct nlattr *tb[IFA_MAX+1];
@@@ -775,7 -775,7 +775,7 @@@ static struct in_ifaddr *find_matching_
        return NULL;
  }
  
 -static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 +static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
  {
        struct net *net = sock_net(skb->sk);
        struct in_ifaddr *ifa;
                if (nlh->nlmsg_flags & NLM_F_EXCL ||
                    !(nlh->nlmsg_flags & NLM_F_REPLACE))
                        return -EEXIST;
-               set_ifa_lifetime(ifa_existing, valid_lft, prefered_lft);
+               ifa = ifa_existing;
+               set_ifa_lifetime(ifa, valid_lft, prefered_lft);
+               rtmsg_ifa(RTM_NEWADDR, ifa, nlh, NETLINK_CB(skb).portid);
+               blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa);
        }
        return 0;
  }
@@@ -1499,8 -1501,6 +1501,8 @@@ static int inet_dump_ifaddr(struct sk_b
                idx = 0;
                head = &net->dev_index_head[h];
                rcu_read_lock();
 +              cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
 +                        net->dev_base_seq;
                hlist_for_each_entry_rcu(dev, head, index_hlist) {
                        if (idx < s_idx)
                                goto cont;
                                        rcu_read_unlock();
                                        goto done;
                                }
 +                              nl_dump_check_consistent(cb, nlmsg_hdr(skb));
                        }
  cont:
                        idx++;
@@@ -1733,7 -1732,8 +1735,7 @@@ static const struct nla_policy devconf_
  };
  
  static int inet_netconf_get_devconf(struct sk_buff *in_skb,
 -                                  struct nlmsghdr *nlh,
 -                                  void *arg)
 +                                  struct nlmsghdr *nlh)
  {
        struct net *net = sock_net(in_skb->sk);
        struct nlattr *tb[NETCONFA_MAX+1];
@@@ -1793,77 -1793,6 +1795,77 @@@ errout
        return err;
  }
  
 +static int inet_netconf_dump_devconf(struct sk_buff *skb,
 +                                   struct netlink_callback *cb)
 +{
 +      struct net *net = sock_net(skb->sk);
 +      int h, s_h;
 +      int idx, s_idx;
 +      struct net_device *dev;
 +      struct in_device *in_dev;
 +      struct hlist_head *head;
 +
 +      s_h = cb->args[0];
 +      s_idx = idx = cb->args[1];
 +
 +      for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
 +              idx = 0;
 +              head = &net->dev_index_head[h];
 +              rcu_read_lock();
 +              cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
 +                        net->dev_base_seq;
 +              hlist_for_each_entry_rcu(dev, head, index_hlist) {
 +                      if (idx < s_idx)
 +                              goto cont;
 +                      in_dev = __in_dev_get_rcu(dev);
 +                      if (!in_dev)
 +                              goto cont;
 +
 +                      if (inet_netconf_fill_devconf(skb, dev->ifindex,
 +                                                    &in_dev->cnf,
 +                                                    NETLINK_CB(cb->skb).portid,
 +                                                    cb->nlh->nlmsg_seq,
 +                                                    RTM_NEWNETCONF,
 +                                                    NLM_F_MULTI,
 +                                                    -1) <= 0) {
 +                              rcu_read_unlock();
 +                              goto done;
 +                      }
 +                      nl_dump_check_consistent(cb, nlmsg_hdr(skb));
 +cont:
 +                      idx++;
 +              }
 +              rcu_read_unlock();
 +      }
 +      if (h == NETDEV_HASHENTRIES) {
 +              if (inet_netconf_fill_devconf(skb, NETCONFA_IFINDEX_ALL,
 +                                            net->ipv4.devconf_all,
 +                                            NETLINK_CB(cb->skb).portid,
 +                                            cb->nlh->nlmsg_seq,
 +                                            RTM_NEWNETCONF, NLM_F_MULTI,
 +                                            -1) <= 0)
 +                      goto done;
 +              else
 +                      h++;
 +      }
 +      if (h == NETDEV_HASHENTRIES + 1) {
 +              if (inet_netconf_fill_devconf(skb, NETCONFA_IFINDEX_DEFAULT,
 +                                            net->ipv4.devconf_dflt,
 +                                            NETLINK_CB(cb->skb).portid,
 +                                            cb->nlh->nlmsg_seq,
 +                                            RTM_NEWNETCONF, NLM_F_MULTI,
 +                                            -1) <= 0)
 +                      goto done;
 +              else
 +                      h++;
 +      }
 +done:
 +      cb->args[0] = h;
 +      cb->args[1] = idx;
 +
 +      return skb->len;
 +}
 +
  #ifdef CONFIG_SYSCTL
  
  static void devinet_copy_dflt_conf(struct net *net, int i)
@@@ -2268,6 -2197,6 +2270,6 @@@ void __init devinet_init(void
        rtnl_register(PF_INET, RTM_DELADDR, inet_rtm_deladdr, NULL, NULL);
        rtnl_register(PF_INET, RTM_GETADDR, NULL, inet_dump_ifaddr, NULL);
        rtnl_register(PF_INET, RTM_GETNETCONF, inet_netconf_get_devconf,
 -                    NULL, NULL);
 +                    inet_netconf_dump_devconf, NULL);
  }
  
index 938e0b7ea1bd6b46fb12ab9b9d1cbf13aa17fb7a,cb631143721c0afb13152121c74a9d49f51e99dc..590f767db5d4df887c201597ee22f395d8a6869b
@@@ -18,8 -18,9 +18,8 @@@
  static int ip6t_npt_checkentry(const struct xt_tgchk_param *par)
  {
        struct ip6t_npt_tginfo *npt = par->targinfo;
 -      __wsum src_sum = 0, dst_sum = 0;
        struct in6_addr pfx;
 -      unsigned int i;
 +      __wsum src_sum, dst_sum;
  
        if (npt->src_pfx_len > 64 || npt->dst_pfx_len > 64)
                return -EINVAL;
        if (!ipv6_addr_equal(&pfx, &npt->dst_pfx.in6))
                return -EINVAL;
  
 -      for (i = 0; i < ARRAY_SIZE(npt->src_pfx.in6.s6_addr16); i++) {
 -              src_sum = csum_add(src_sum,
 -                              (__force __wsum)npt->src_pfx.in6.s6_addr16[i]);
 -              dst_sum = csum_add(dst_sum,
 -                              (__force __wsum)npt->dst_pfx.in6.s6_addr16[i]);
 -      }
 +      src_sum = csum_partial(&npt->src_pfx.in6, sizeof(npt->src_pfx.in6), 0);
 +      dst_sum = csum_partial(&npt->dst_pfx.in6, sizeof(npt->dst_pfx.in6), 0);
  
        npt->adjustment = ~csum_fold(csum_sub(src_sum, dst_sum));
        return 0;
@@@ -52,7 -57,7 +52,7 @@@ static bool ip6t_npt_map_pfx(const stru
                if (pfx_len - i >= 32)
                        mask = 0;
                else
-                       mask = htonl(~((1 << (pfx_len - i)) - 1));
+                       mask = htonl((1 << (i - pfx_len + 32)) - 1);
  
                idx = i / 32;
                addr->s6_addr32[idx] &= mask;
diff --combined net/ipv6/tcp_ipv6.c
index 1033d2b1d81e93221b931fddbb0aafcf32d02962,46a5be85be87ebed43ec8b01d6b63263df556279..e51bd1a58264eb9a98d5ed863967ee799a802b44
@@@ -386,6 -386,7 +386,7 @@@ static void tcp_v6_err(struct sk_buff *
  
                if (dst)
                        dst->ops->redirect(dst, sk, skb);
+               goto out;
        }
  
        if (type == ICMPV6_PKT_TOOBIG) {
@@@ -461,6 -462,7 +462,6 @@@ out
  static int tcp_v6_send_synack(struct sock *sk, struct dst_entry *dst,
                              struct flowi6 *fl6,
                              struct request_sock *req,
 -                            struct request_values *rvp,
                              u16 queue_mapping)
  {
        struct inet6_request_sock *treq = inet6_rsk(req);
        if (!dst && (dst = inet6_csk_route_req(sk, fl6, req)) == NULL)
                goto done;
  
 -      skb = tcp_make_synack(sk, dst, req, rvp, NULL);
 +      skb = tcp_make_synack(sk, dst, req, NULL);
  
        if (skb) {
                __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr);
@@@ -487,12 -489,13 +488,12 @@@ done
        return err;
  }
  
 -static int tcp_v6_rtx_synack(struct sock *sk, struct request_sock *req,
 -                           struct request_values *rvp)
 +static int tcp_v6_rtx_synack(struct sock *sk, struct request_sock *req)
  {
        struct flowi6 fl6;
        int res;
  
 -      res = tcp_v6_send_synack(sk, NULL, &fl6, req, rvp, 0);
 +      res = tcp_v6_send_synack(sk, NULL, &fl6, req, 0);
        if (!res)
                TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS);
        return res;
@@@ -945,7 -948,9 +946,7 @@@ static struct sock *tcp_v6_hnd_req(stru
   */
  static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
  {
 -      struct tcp_extend_values tmp_ext;
        struct tcp_options_received tmp_opt;
 -      const u8 *hash_location;
        struct request_sock *req;
        struct inet6_request_sock *treq;
        struct ipv6_pinfo *np = inet6_sk(sk);
        tcp_clear_options(&tmp_opt);
        tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
        tmp_opt.user_mss = tp->rx_opt.user_mss;
 -      tcp_parse_options(skb, &tmp_opt, &hash_location, 0, NULL);
 -
 -      if (tmp_opt.cookie_plus > 0 &&
 -          tmp_opt.saw_tstamp &&
 -          !tp->rx_opt.cookie_out_never &&
 -          (sysctl_tcp_cookie_size > 0 ||
 -           (tp->cookie_values != NULL &&
 -            tp->cookie_values->cookie_desired > 0))) {
 -              u8 *c;
 -              u32 *d;
 -              u32 *mess = &tmp_ext.cookie_bakery[COOKIE_DIGEST_WORDS];
 -              int l = tmp_opt.cookie_plus - TCPOLEN_COOKIE_BASE;
 -
 -              if (tcp_cookie_generator(&tmp_ext.cookie_bakery[0]) != 0)
 -                      goto drop_and_free;
 -
 -              /* Secret recipe starts with IP addresses */
 -              d = (__force u32 *)&ipv6_hdr(skb)->daddr.s6_addr32[0];
 -              *mess++ ^= *d++;
 -              *mess++ ^= *d++;
 -              *mess++ ^= *d++;
 -              *mess++ ^= *d++;
 -              d = (__force u32 *)&ipv6_hdr(skb)->saddr.s6_addr32[0];
 -              *mess++ ^= *d++;
 -              *mess++ ^= *d++;
 -              *mess++ ^= *d++;
 -              *mess++ ^= *d++;
 -
 -              /* plus variable length Initiator Cookie */
 -              c = (u8 *)mess;
 -              while (l-- > 0)
 -                      *c++ ^= *hash_location++;
 -
 -              want_cookie = false;    /* not our kind of cookie */
 -              tmp_ext.cookie_out_never = 0; /* false */
 -              tmp_ext.cookie_plus = tmp_opt.cookie_plus;
 -      } else if (!tp->rx_opt.cookie_in_always) {
 -              /* redundant indications, but ensure initialization. */
 -              tmp_ext.cookie_out_never = 1; /* true */
 -              tmp_ext.cookie_plus = 0;
 -      } else {
 -              goto drop_and_free;
 -      }
 -      tmp_ext.cookie_in_always = tp->rx_opt.cookie_in_always;
 +      tcp_parse_options(skb, &tmp_opt, 0, NULL);
  
        if (want_cookie && !tmp_opt.saw_tstamp)
                tcp_clear_options(&tmp_opt);
@@@ -1061,6 -1109,7 +1062,6 @@@ have_isn
                goto drop_and_release;
  
        if (tcp_v6_send_synack(sk, dst, &fl6, req,
 -                             (struct request_values *)&tmp_ext,
                               skb_get_queue_mapping(skb)) ||
            want_cookie)
                goto drop_and_free;
diff --combined net/iucv/af_iucv.c
index 7dfb9ed93698b5a6e029e0c95007d7da56b8424c,bf69358200019c28c18472cc852ccd6b3f74f7cf..e165e8dc962e7ea98ab22312709022f572ca4a89
@@@ -1328,6 -1328,8 +1328,8 @@@ static int iucv_sock_recvmsg(struct kio
        struct sk_buff *skb, *rskb, *cskb;
        int err = 0;
  
+       msg->msg_namelen = 0;
        if ((sk->sk_state == IUCV_DISCONN) &&
            skb_queue_empty(&iucv->backlog_skb_q) &&
            skb_queue_empty(&sk->sk_receive_queue) &&
@@@ -1461,8 -1463,7 +1463,8 @@@ unsigned int iucv_sock_poll(struct fil
                return iucv_accept_poll(sk);
  
        if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 -              mask |= POLLERR;
 +              mask |= POLLERR |
 +                      (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
  
        if (sk->sk_shutdown & RCV_SHUTDOWN)
                mask |= POLLRDHUP;
diff --combined net/mac80211/cfg.c
index 1d1ddabd89caf34167fd092baf63262c9a850aef,a6893602f87a753ebafeae0d0b8f449bdc7251f7..c34e6d78a592b302969a998777812cd7639e84c5
@@@ -254,7 -254,7 +254,7 @@@ static int ieee80211_del_key(struct wip
                goto out_unlock;
        }
  
 -      __ieee80211_key_free(key);
 +      __ieee80211_key_free(key, true);
  
        ret = 0;
   out_unlock:
@@@ -1035,12 -1035,9 +1035,12 @@@ static int ieee80211_stop_ap(struct wip
                sta_info_flush_defer(vlan);
        sta_info_flush_defer(sdata);
        rcu_barrier();
 -      list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
 +      list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
                sta_info_flush_cleanup(vlan);
 +              ieee80211_free_keys(vlan);
 +      }
        sta_info_flush_cleanup(sdata);
 +      ieee80211_free_keys(sdata);
  
        sdata->vif.bss_conf.enable_beacon = false;
        clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
@@@ -1180,18 -1177,6 +1180,18 @@@ static int sta_apply_parameters(struct 
                        mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
                if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
                        set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
 +      } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
 +              /*
 +               * TDLS -- everything follows authorized, but
 +               * only becoming authorized is possible, not
 +               * going back
 +               */
 +              if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
 +                      set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
 +                             BIT(NL80211_STA_FLAG_ASSOCIATED);
 +                      mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
 +                              BIT(NL80211_STA_FLAG_ASSOCIATED);
 +              }
        }
  
        ret = sta_apply_auth_flags(local, sta, mask, set);
        if (ieee80211_vif_is_mesh(&sdata->vif)) {
  #ifdef CONFIG_MAC80211_MESH
                u32 changed = 0;
 -              if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) {
 +
 +              if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
                        switch (params->plink_state) {
                        case NL80211_PLINK_ESTAB:
                                if (sta->plink_state != NL80211_PLINK_ESTAB)
                                /*  nothing  */
                                break;
                        }
 -              } else {
 -                      switch (params->plink_action) {
 -                      case PLINK_ACTION_OPEN:
 -                              changed |= mesh_plink_open(sta);
 -                              break;
 -                      case PLINK_ACTION_BLOCK:
 -                              changed |= mesh_plink_block(sta);
 -                              break;
 -                      }
 +              }
 +
 +              switch (params->plink_action) {
 +              case NL80211_PLINK_ACTION_NO_ACTION:
 +                      /* nothing */
 +                      break;
 +              case NL80211_PLINK_ACTION_OPEN:
 +                      changed |= mesh_plink_open(sta);
 +                      break;
 +              case NL80211_PLINK_ACTION_BLOCK:
 +                      changed |= mesh_plink_block(sta);
 +                      break;
                }
  
                if (params->local_pm)
@@@ -1365,10 -1346,8 +1365,10 @@@ static int ieee80211_add_station(struc
         * defaults -- if userspace wants something else we'll
         * change it accordingly in sta_apply_parameters()
         */
 -      sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
 -      sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
 +      if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) {
 +              sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
 +              sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
 +      }
  
        err = sta_apply_parameters(local, sta, params);
        if (err) {
        }
  
        /*
 -       * for TDLS, rate control should be initialized only when supported
 -       * rates are known.
 +       * for TDLS, rate control should be initialized only when
 +       * rates are known and station is marked authorized
         */
        if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
                rate_control_rate_init(sta);
@@@ -1415,67 -1394,50 +1415,67 @@@ static int ieee80211_del_station(struc
  }
  
  static int ieee80211_change_station(struct wiphy *wiphy,
 -                                  struct net_device *dev,
 -                                  u8 *mac,
 +                                  struct net_device *dev, u8 *mac,
                                    struct station_parameters *params)
  {
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        struct ieee80211_local *local = wiphy_priv(wiphy);
        struct sta_info *sta;
        struct ieee80211_sub_if_data *vlansdata;
 +      enum cfg80211_station_type statype;
        int err;
  
        mutex_lock(&local->sta_mtx);
  
        sta = sta_info_get_bss(sdata, mac);
        if (!sta) {
 -              mutex_unlock(&local->sta_mtx);
 -              return -ENOENT;
 +              err = -ENOENT;
 +              goto out_err;
        }
  
 -      /* in station mode, some updates are only valid with TDLS */
 -      if (sdata->vif.type == NL80211_IFTYPE_STATION &&
 -          (params->supported_rates || params->ht_capa || params->vht_capa ||
 -           params->sta_modify_mask ||
 -           (params->sta_flags_mask & BIT(NL80211_STA_FLAG_WME))) &&
 -          !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
 -              mutex_unlock(&local->sta_mtx);
 -              return -EINVAL;
 +      switch (sdata->vif.type) {
 +      case NL80211_IFTYPE_MESH_POINT:
 +              if (sdata->u.mesh.user_mpm)
 +                      statype = CFG80211_STA_MESH_PEER_USER;
 +              else
 +                      statype = CFG80211_STA_MESH_PEER_KERNEL;
 +              break;
 +      case NL80211_IFTYPE_ADHOC:
 +              statype = CFG80211_STA_IBSS;
 +              break;
 +      case NL80211_IFTYPE_STATION:
 +              if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
 +                      statype = CFG80211_STA_AP_STA;
 +                      break;
 +              }
 +              if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
 +                      statype = CFG80211_STA_TDLS_PEER_ACTIVE;
 +              else
 +                      statype = CFG80211_STA_TDLS_PEER_SETUP;
 +              break;
 +      case NL80211_IFTYPE_AP:
 +      case NL80211_IFTYPE_AP_VLAN:
 +              statype = CFG80211_STA_AP_CLIENT;
 +              break;
 +      default:
 +              err = -EOPNOTSUPP;
 +              goto out_err;
        }
  
 +      err = cfg80211_check_station_change(wiphy, params, statype);
 +      if (err)
 +              goto out_err;
 +
        if (params->vlan && params->vlan != sta->sdata->dev) {
                bool prev_4addr = false;
                bool new_4addr = false;
  
                vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  
 -              if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
 -                  vlansdata->vif.type != NL80211_IFTYPE_AP) {
 -                      mutex_unlock(&local->sta_mtx);
 -                      return -EINVAL;
 -              }
 -
                if (params->vlan->ieee80211_ptr->use_4addr) {
                        if (vlansdata->u.vlan.sta) {
 -                              mutex_unlock(&local->sta_mtx);
 -                              return -EBUSY;
 +                              err = -EBUSY;
 +                              goto out_err;
                        }
  
                        rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
        }
  
        err = sta_apply_parameters(local, sta, params);
 -      if (err) {
 -              mutex_unlock(&local->sta_mtx);
 -              return err;
 -      }
 +      if (err)
 +              goto out_err;
  
 -      if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates)
 +      /* When peer becomes authorized, init rate control as well */
 +      if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
 +          test_sta_flag(sta, WLAN_STA_AUTHORIZED))
                rate_control_rate_init(sta);
  
        mutex_unlock(&local->sta_mtx);
                ieee80211_recalc_ps(local, -1);
                ieee80211_recalc_ps_vif(sdata);
        }
 +
        return 0;
 +out_err:
 +      mutex_unlock(&local->sta_mtx);
 +      return err;
  }
  
  #ifdef CONFIG_MAC80211_MESH
@@@ -1729,7 -1687,6 +1729,7 @@@ static int copy_mesh_setup(struct ieee8
        ifmsh->mesh_sp_id = setup->sync_method;
        ifmsh->mesh_pp_id = setup->path_sel_proto;
        ifmsh->mesh_pm_id = setup->path_metric;
 +      ifmsh->user_mpm = setup->user_mpm;
        ifmsh->security = IEEE80211_MESH_SEC_NONE;
        if (setup->is_authenticated)
                ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
@@@ -1773,11 -1730,8 +1773,11 @@@ static int ieee80211_update_mesh_config
                conf->dot11MeshTTL = nconf->dot11MeshTTL;
        if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
                conf->element_ttl = nconf->element_ttl;
 -      if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
 +      if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
 +              if (ifmsh->user_mpm)
 +                      return -EBUSY;
                conf->auto_open_plinks = nconf->auto_open_plinks;
 +      }
        if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
                conf->dot11MeshNbrOffsetMaxNeighbor =
                        nconf->dot11MeshNbrOffsetMaxNeighbor;
@@@ -2417,8 -2371,7 +2417,8 @@@ static int ieee80211_start_roc_work(str
                                    struct ieee80211_sub_if_data *sdata,
                                    struct ieee80211_channel *channel,
                                    unsigned int duration, u64 *cookie,
 -                                  struct sk_buff *txskb)
 +                                  struct sk_buff *txskb,
 +                                  enum ieee80211_roc_type type)
  {
        struct ieee80211_roc_work *roc, *tmp;
        bool queued = false;
        roc->duration = duration;
        roc->req_duration = duration;
        roc->frame = txskb;
 +      roc->type = type;
        roc->mgmt_tx_cookie = (unsigned long)txskb;
        roc->sdata = sdata;
        INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
        if (!duration)
                duration = 10;
  
 -      ret = drv_remain_on_channel(local, sdata, channel, duration);
 +      ret = drv_remain_on_channel(local, sdata, channel, duration, type);
        if (ret) {
                kfree(roc);
                return ret;
                 *
                 * If it hasn't started yet, just increase the duration
                 * and add the new one to the list of dependents.
 +               * If the type of the new ROC has higher priority, modify the
 +               * type of the previous one to match that of the new one.
                 */
                if (!tmp->started) {
                        list_add_tail(&roc->list, &tmp->dependents);
                        tmp->duration = max(tmp->duration, roc->duration);
 +                      tmp->type = max(tmp->type, roc->type);
                        queued = true;
                        break;
                }
                        /*
                         * In the offloaded ROC case, if it hasn't begun, add
                         * this new one to the dependent list to be handled
 -                       * when the the master one begins. If it has begun,
 +                       * when the master one begins. If it has begun,
                         * check that there's still a minimum time left and
                         * if so, start this one, transmitting the frame, but
 -                       * add it to the list directly after this one with a
 +                       * add it to the list directly after this one with
                         * a reduced time so we'll ask the driver to execute
                         * it right after finishing the previous one, in the
                         * hope that it'll also be executed right afterwards,
                         * effectively extending the old one.
                         * If there's no minimum time left, just add it to the
                         * normal list.
 +                       * TODO: the ROC type is ignored here, assuming that it
 +                       * is better to immediately use the current ROC.
                         */
                        if (!tmp->hw_begun) {
                                list_add_tail(&roc->list, &tmp->dependents);
@@@ -2610,8 -2557,7 +2610,8 @@@ static int ieee80211_remain_on_channel(
  
        mutex_lock(&local->mtx);
        ret = ieee80211_start_roc_work(local, sdata, chan,
 -                                     duration, cookie, NULL);
 +                                     duration, cookie, NULL,
 +                                     IEEE80211_ROC_TYPE_NORMAL);
        mutex_unlock(&local->mtx);
  
        return ret;
@@@ -2636,7 -2582,7 +2636,7 @@@ static int ieee80211_cancel_roc(struct 
                        list_del(&dep->list);
                        mutex_unlock(&local->mtx);
  
-                       ieee80211_roc_notify_destroy(dep);
+                       ieee80211_roc_notify_destroy(dep, true);
                        return 0;
                }
  
                        ieee80211_start_next_roc(local);
                mutex_unlock(&local->mtx);
  
-               ieee80211_roc_notify_destroy(found);
+               ieee80211_roc_notify_destroy(found, true);
        } else {
                /* work may be pending so use it all the time */
                found->abort = true;
  
                /* work will clean up etc */
                flush_delayed_work(&found->work);
+               WARN_ON(!found->to_be_freed);
+               kfree(found);
        }
  
        return 0;
@@@ -2844,8 -2792,7 +2846,8 @@@ static int ieee80211_mgmt_tx(struct wip
  
        /* This will handle all kinds of coalescing and immediate TX */
        ret = ieee80211_start_roc_work(local, sdata, chan,
 -                                     wait, cookie, skb);
 +                                     wait, cookie, skb,
 +                                     IEEE80211_ROC_TYPE_MGMT_TX);
        if (ret)
                kfree_skb(skb);
   out_unlock:
index f4433f081e77294f14fbb40075bbdd1c69c852ee,5672533a083279ddc50fe98a09bbd4363a9fc731..e140184c28ceefb4008a08988dbb962548f4269a
@@@ -309,13 -309,13 +309,14 @@@ struct ieee80211_roc_work 
        struct ieee80211_channel *chan;
  
        bool started, abort, hw_begun, notified;
+       bool to_be_freed;
  
        unsigned long hw_start_time;
  
        u32 duration, req_duration;
        struct sk_buff *frame;
        u64 cookie, mgmt_tx_cookie;
 +      enum ieee80211_roc_type type;
  };
  
  /* flags used in struct ieee80211_if_managed.flags */
@@@ -401,6 -401,7 +402,6 @@@ struct ieee80211_if_managed 
  
        u16 aid;
  
 -      unsigned long timers_running; /* used for quiesce/restart */
        bool powersave; /* powersave requested for this iface */
        bool broken_ap; /* AP is broken -- turn off powersave */
        u8 dtim_period;
  
        struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
        struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
 +      struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
 +      struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
  };
  
  struct ieee80211_if_ibss {
  
        u32 basic_rates;
  
 -      bool timer_running;
 -
        bool fixed_bssid;
        bool fixed_channel;
        bool privacy;
@@@ -543,6 -544,8 +544,6 @@@ struct ieee80211_if_mesh 
        struct timer_list mesh_path_timer;
        struct timer_list mesh_path_root_timer;
  
 -      unsigned long timers_running;
 -
        unsigned long wrkq_flags;
  
        u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
                IEEE80211_MESH_SEC_AUTHED = 0x1,
                IEEE80211_MESH_SEC_SECURED = 0x2,
        } security;
 +      bool user_mpm;
        /* Extensible Synchronization Framework */
        const struct ieee80211_mesh_sync_ops *sync_ops;
        s64 sync_offset_clockdrift_max;
@@@ -681,8 -683,6 +682,8 @@@ struct ieee80211_sub_if_data 
  
        /* count for keys needing tailroom space allocation */
        int crypto_tx_tailroom_needed_cnt;
 +      int crypto_tx_tailroom_pending_dec;
 +      struct delayed_work dec_tailroom_needed_wk;
  
        struct net_device *dev;
        struct ieee80211_local *local;
        } debugfs;
  #endif
  
 -#ifdef CONFIG_PM
 -      struct ieee80211_bss_conf suspend_bss_conf;
 -#endif
 -
        /* must be last, dynamically sized area in this! */
        struct ieee80211_vif vif;
  };
@@@ -1133,6 -1137,11 +1134,6 @@@ struct ieee80211_local 
  
        struct ieee80211_sub_if_data __rcu *p2p_sdata;
  
 -      /* dummy netdev for use w/ NAPI */
 -      struct net_device napi_dev;
 -
 -      struct napi_struct napi;
 -
        /* virtual monitor interface */
        struct ieee80211_sub_if_data __rcu *monitor_sdata;
        struct cfg80211_chan_def monitor_chandef;
@@@ -1275,6 -1284,8 +1276,6 @@@ voi
  ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
                                 const struct ieee80211_channel_sw_ie *sw_elem,
                                 struct ieee80211_bss *bss, u64 timestamp);
 -void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata);
 -void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
  void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
  void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
                                  struct sk_buff *skb);
@@@ -1292,6 -1303,8 +1293,6 @@@ void ieee80211_ibss_rx_no_sta(struct ie
  int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
                        struct cfg80211_ibss_params *params);
  int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
 -void ieee80211_ibss_quiesce(struct ieee80211_sub_if_data *sdata);
 -void ieee80211_ibss_restart(struct ieee80211_sub_if_data *sdata);
  void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
  void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
                                   struct sk_buff *skb);
@@@ -1335,7 -1348,7 +1336,7 @@@ void ieee80211_offchannel_return(struc
  void ieee80211_roc_setup(struct ieee80211_local *local);
  void ieee80211_start_next_roc(struct ieee80211_local *local);
  void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata);
- void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc);
+ void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
  void ieee80211_sw_roc_work(struct work_struct *work);
  void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
  
@@@ -1349,6 -1362,7 +1350,7 @@@ int ieee80211_if_change_type(struct iee
                             enum nl80211_iftype type);
  void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
  void ieee80211_remove_interfaces(struct ieee80211_local *local);
+ u32 ieee80211_idle_off(struct ieee80211_local *local);
  void ieee80211_recalc_idle(struct ieee80211_local *local);
  void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
                                    const int offset);
@@@ -1429,8 -1443,6 +1431,8 @@@ void ieee80211_sta_set_rx_nss(struct st
  void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
                                 struct sta_info *sta, u8 opmode,
                                 enum ieee80211_band band, bool nss_only);
 +void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
 +                                    struct ieee80211_sta_vht_cap *vht_cap);
  
  /* Spectrum management */
  void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
diff --combined net/mac80211/iface.c
index 7530c60fe502e9fda8c9ab2875f471e43d75fe90,58150f877ec3fe83f29adb2df4caf5bb617e3358..a2b5e17036bb033321a1b3f2b9592698e7c4005e
@@@ -78,7 -78,7 +78,7 @@@ void ieee80211_recalc_txpower(struct ie
                ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER);
  }
  
static u32 ieee80211_idle_off(struct ieee80211_local *local)
+ u32 ieee80211_idle_off(struct ieee80211_local *local)
  {
        if (!(local->hw.conf.flags & IEEE80211_CONF_IDLE))
                return 0;
@@@ -488,6 -488,8 +488,6 @@@ int ieee80211_do_open(struct wireless_d
                res = drv_start(local);
                if (res)
                        goto err_del_bss;
 -              if (local->ops->napi_poll)
 -                      napi_enable(&local->napi);
                /* we're brought up, everything changes */
                hw_reconf_flags = ~0;
                ieee80211_led_radio(local, true);
@@@ -839,16 -841,14 +839,16 @@@ static void ieee80211_do_stop(struct ie
                rcu_barrier();
                sta_info_flush_cleanup(sdata);
  
 -              skb_queue_purge(&sdata->skb_queue);
 -
                /*
                 * Free all remaining keys, there shouldn't be any,
 -               * except maybe group keys in AP more or WDS?
 +               * except maybe in WDS mode?
                 */
                ieee80211_free_keys(sdata);
  
 +              /* fall through */
 +      case NL80211_IFTYPE_AP:
 +              skb_queue_purge(&sdata->skb_queue);
 +
                drv_remove_interface_debugfs(local, sdata);
  
                if (going_down)
        ieee80211_recalc_ps(local, -1);
  
        if (local->open_count == 0) {
 -              if (local->ops->napi_poll)
 -                      napi_disable(&local->napi);
                ieee80211_clear_tx_pending(local);
                ieee80211_stop_device(local);
  
@@@ -1548,8 -1550,6 +1548,8 @@@ int ieee80211_if_add(struct ieee80211_l
        INIT_WORK(&sdata->cleanup_stations_wk, ieee80211_cleanup_sdata_stas_wk);
        INIT_DELAYED_WORK(&sdata->dfs_cac_timer_work,
                          ieee80211_dfs_cac_timer_work);
 +      INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
 +                        ieee80211_delayed_tailroom_dec);
  
        for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
                struct ieee80211_supported_band *sband;
index db547fceaeb9cc68d7313aa004c25f8ac61d1389,430bd254e49693bf7e62744843fff8c10a2acb9a..950c95bec13dc7b3b69cf6abf18d1bbe8b787c6a
@@@ -277,7 -277,7 +277,7 @@@ void ieee80211_start_next_roc(struct ie
                        duration = 10;
  
                ret = drv_remain_on_channel(local, roc->sdata, roc->chan,
 -                                          duration);
 +                                          duration, roc->type);
  
                roc->started = true;
  
        }
  }
  
- void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
+ void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free)
  {
        struct ieee80211_roc_work *dep, *tmp;
  
+       if (WARN_ON(roc->to_be_freed))
+               return;
        /* was never transmitted */
        if (roc->frame) {
                cfg80211_mgmt_tx_status(&roc->sdata->wdev,
                                                   GFP_KERNEL);
  
        list_for_each_entry_safe(dep, tmp, &roc->dependents, list)
-               ieee80211_roc_notify_destroy(dep);
+               ieee80211_roc_notify_destroy(dep, true);
  
-       kfree(roc);
+       if (free)
+               kfree(roc);
+       else
+               roc->to_be_freed = true;
  }
  
  void ieee80211_sw_roc_work(struct work_struct *work)
  
        mutex_lock(&local->mtx);
  
+       if (roc->to_be_freed)
+               goto out_unlock;
        if (roc->abort)
                goto finish;
  
   finish:
                list_del(&roc->list);
                started = roc->started;
-               ieee80211_roc_notify_destroy(roc);
+               ieee80211_roc_notify_destroy(roc, !roc->abort);
  
                if (started) {
                        drv_flush(local, false);
@@@ -410,7 -419,7 +419,7 @@@ static void ieee80211_hw_roc_done(struc
  
        list_del(&roc->list);
  
-       ieee80211_roc_notify_destroy(roc);
+       ieee80211_roc_notify_destroy(roc, true);
  
        /* if there's another roc, start it now */
        ieee80211_start_next_roc(local);
@@@ -460,12 -469,14 +469,14 @@@ void ieee80211_roc_purge(struct ieee802
        list_for_each_entry_safe(roc, tmp, &tmp_list, list) {
                if (local->ops->remain_on_channel) {
                        list_del(&roc->list);
-                       ieee80211_roc_notify_destroy(roc);
+                       ieee80211_roc_notify_destroy(roc, true);
                } else {
                        ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
  
                        /* work will clean up etc */
                        flush_delayed_work(&roc->work);
+                       WARN_ON(!roc->to_be_freed);
+                       kfree(roc);
                }
        }
  
index 6c69fbdb8361ad0ed717bc40a52462f888df57e7,fedee394366187cf35bfa242c9cd1584f0eb0108..ebb67d33bd63adbee3cb0c0d889e81a932482a45
@@@ -545,20 -545,16 +545,20 @@@ out_init
        return ret;
  }
  
 -static void nf_conntrack_pernet_exit(struct net *net)
 +static void nf_conntrack_pernet_exit(struct list_head *net_exit_list)
  {
 -      nf_conntrack_standalone_fini_sysctl(net);
 -      nf_conntrack_standalone_fini_proc(net);
 -      nf_conntrack_cleanup_net(net);
 +      struct net *net;
 +
 +      list_for_each_entry(net, net_exit_list, exit_list) {
 +              nf_conntrack_standalone_fini_sysctl(net);
 +              nf_conntrack_standalone_fini_proc(net);
 +      }
 +      nf_conntrack_cleanup_net_list(net_exit_list);
  }
  
  static struct pernet_operations nf_conntrack_net_ops = {
 -      .init = nf_conntrack_pernet_init,
 -      .exit = nf_conntrack_pernet_exit,
 +      .init           = nf_conntrack_pernet_init,
 +      .exit_batch     = nf_conntrack_pernet_exit,
  };
  
  static int __init nf_conntrack_standalone_init(void)
                register_net_sysctl(&init_net, "net", nf_ct_netfilter_table);
        if (!nf_ct_netfilter_header) {
                pr_err("nf_conntrack: can't register to sysctl.\n");
+               ret = -ENOMEM;
                goto out_sysctl;
        }
  #endif
diff --combined net/nfc/llcp/llcp.c
index bb67b98b979728e88624ea1bfb8349be190a183e,ee25f25f0cd638367cc4a6668c44e907945c9469..7de0368aff0c83b35d05061f6d205e26415c57c3
@@@ -107,8 -107,6 +107,6 @@@ static void nfc_llcp_socket_release(str
                                accept_sk->sk_state_change(sk);
  
                                bh_unlock_sock(accept_sk);
-                               sock_orphan(accept_sk);
                        }
  
                        if (listen == true) {
  
                bh_unlock_sock(sk);
  
-               sock_orphan(sk);
                sk_del_node_init(sk);
        }
  
  
                bh_unlock_sock(sk);
  
-               sock_orphan(sk);
                sk_del_node_init(sk);
        }
  
@@@ -188,9 -182,6 +182,9 @@@ static void local_cleanup(struct nfc_ll
        cancel_work_sync(&local->rx_work);
        cancel_work_sync(&local->timeout_work);
        kfree_skb(local->rx_pending);
 +      del_timer_sync(&local->sdreq_timer);
 +      cancel_work_sync(&local->sdreq_timeout_work);
 +      nfc_llcp_free_sdp_tlv_list(&local->pending_sdreqs);
  }
  
  static void local_release(struct kref *ref)
@@@ -268,47 -259,6 +262,47 @@@ static void nfc_llcp_symm_timer(unsigne
        schedule_work(&local->timeout_work);
  }
  
 +static void nfc_llcp_sdreq_timeout_work(struct work_struct *work)
 +{
 +      unsigned long time;
 +      HLIST_HEAD(nl_sdres_list);
 +      struct hlist_node *n;
 +      struct nfc_llcp_sdp_tlv *sdp;
 +      struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local,
 +                                                  sdreq_timeout_work);
 +
 +      mutex_lock(&local->sdreq_lock);
 +
 +      time = jiffies - msecs_to_jiffies(3 * local->remote_lto);
 +
 +      hlist_for_each_entry_safe(sdp, n, &local->pending_sdreqs, node) {
 +              if (time_after(sdp->time, time))
 +                      continue;
 +
 +              sdp->sap = LLCP_SDP_UNBOUND;
 +
 +              hlist_del(&sdp->node);
 +
 +              hlist_add_head(&sdp->node, &nl_sdres_list);
 +      }
 +
 +      if (!hlist_empty(&local->pending_sdreqs))
 +              mod_timer(&local->sdreq_timer,
 +                        jiffies + msecs_to_jiffies(3 * local->remote_lto));
 +
 +      mutex_unlock(&local->sdreq_lock);
 +
 +      if (!hlist_empty(&nl_sdres_list))
 +              nfc_genl_llc_send_sdres(local->dev, &nl_sdres_list);
 +}
 +
 +static void nfc_llcp_sdreq_timer(unsigned long data)
 +{
 +      struct nfc_llcp_local *local = (struct nfc_llcp_local *) data;
 +
 +      schedule_work(&local->sdreq_timeout_work);
 +}
 +
  struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev)
  {
        struct nfc_llcp_local *local, *n;
@@@ -852,6 -802,8 +846,6 @@@ static void nfc_llcp_recv_ui(struct nfc
        ui_cb->dsap = dsap;
        ui_cb->ssap = ssap;
  
 -      printk("%s %d %d\n", __func__, dsap, ssap);
 -
        pr_debug("%d %d\n", dsap, ssap);
  
        /* We're looking for a bound socket, not a client one */
                skb_get(skb);
        } else {
                pr_err("Receive queue is full\n");
-               kfree_skb(skb);
        }
  
        nfc_llcp_sock_put(llcp_sock);
@@@ -949,9 -900,7 +942,9 @@@ static void nfc_llcp_recv_connect(struc
        new_sock = nfc_llcp_sock(new_sk);
        new_sock->dev = local->dev;
        new_sock->local = nfc_llcp_local_get(local);
 -      new_sock->miu = local->remote_miu;
 +      new_sock->rw = sock->rw;
 +      new_sock->miux = sock->miux;
 +      new_sock->remote_miu = local->remote_miu;
        new_sock->nfc_protocol = sock->nfc_protocol;
        new_sock->dsap = ssap;
        new_sock->target_idx = local->target_idx;
@@@ -1005,11 -954,11 +998,11 @@@ int nfc_llcp_queue_i_frames(struct nfc_
  
        pr_debug("Remote ready %d tx queue len %d remote rw %d",
                 sock->remote_ready, skb_queue_len(&sock->tx_pending_queue),
 -               sock->rw);
 +               sock->remote_rw);
  
        /* Try to queue some I frames for transmission */
        while (sock->remote_ready &&
 -             skb_queue_len(&sock->tx_pending_queue) < sock->rw) {
 +             skb_queue_len(&sock->tx_pending_queue) < sock->remote_rw) {
                struct sk_buff *pdu;
  
                pdu = skb_dequeue(&sock->tx_queue);
@@@ -1072,7 -1021,6 +1065,6 @@@ static void nfc_llcp_recv_hdlc(struct n
                        skb_get(skb);
                } else {
                        pr_err("Receive queue is full\n");
-                       kfree_skb(skb);
                }
        }
  
@@@ -1230,10 -1178,6 +1222,10 @@@ static void nfc_llcp_recv_snl(struct nf
        u16 tlv_len, offset;
        char *service_name;
        size_t service_name_len;
 +      struct nfc_llcp_sdp_tlv *sdp;
 +      HLIST_HEAD(llc_sdres_list);
 +      size_t sdres_tlvs_len;
 +      HLIST_HEAD(nl_sdres_list);
  
        dsap = nfc_llcp_dsap(skb);
        ssap = nfc_llcp_ssap(skb);
        tlv = &skb->data[LLCP_HEADER_SIZE];
        tlv_len = skb->len - LLCP_HEADER_SIZE;
        offset = 0;
 +      sdres_tlvs_len = 0;
  
        while (offset < tlv_len) {
                type = tlv[0];
                            !strncmp(service_name, "urn:nfc:sn:sdp",
                                     service_name_len)) {
                                sap = 1;
 -                              goto send_snl;
 +                              goto add_snl;
                        }
  
                        llcp_sock = nfc_llcp_sock_from_sn(local, service_name,
                                                          service_name_len);
                        if (!llcp_sock) {
                                sap = 0;
 -                              goto send_snl;
 +                              goto add_snl;
                        }
  
                        /*
  
                                if (sap == LLCP_SAP_MAX) {
                                        sap = 0;
 -                                      goto send_snl;
 +                                      goto add_snl;
                                }
  
                                client_count =
  
                        pr_debug("%p %d\n", llcp_sock, sap);
  
 -send_snl:
 -                      nfc_llcp_send_snl(local, tid, sap);
 +add_snl:
 +                      sdp = nfc_llcp_build_sdres_tlv(tid, sap);
 +                      if (sdp == NULL)
 +                              goto exit;
 +
 +                      sdres_tlvs_len += sdp->tlv_len;
 +                      hlist_add_head(&sdp->node, &llc_sdres_list);
 +                      break;
 +
 +              case LLCP_TLV_SDRES:
 +                      mutex_lock(&local->sdreq_lock);
 +
 +                      pr_debug("LLCP_TLV_SDRES: searching tid %d\n", tlv[2]);
 +
 +                      hlist_for_each_entry(sdp, &local->pending_sdreqs, node) {
 +                              if (sdp->tid != tlv[2])
 +                                      continue;
 +
 +                              sdp->sap = tlv[3];
 +
 +                              pr_debug("Found: uri=%s, sap=%d\n",
 +                                       sdp->uri, sdp->sap);
 +
 +                              hlist_del(&sdp->node);
 +
 +                              hlist_add_head(&sdp->node, &nl_sdres_list);
 +
 +                              break;
 +                      }
 +
 +                      mutex_unlock(&local->sdreq_lock);
                        break;
  
                default:
                offset += length + 2;
                tlv += length + 2;
        }
 +
 +exit:
 +      if (!hlist_empty(&nl_sdres_list))
 +              nfc_genl_llc_send_sdres(local->dev, &nl_sdres_list);
 +
 +      if (!hlist_empty(&llc_sdres_list))
 +              nfc_llcp_send_snl_sdres(local, &llc_sdres_list, sdres_tlvs_len);
  }
  
  static void nfc_llcp_rx_work(struct work_struct *work)
@@@ -1540,13 -1447,6 +1532,13 @@@ int nfc_llcp_register_device(struct nfc
        local->remote_miu = LLCP_DEFAULT_MIU;
        local->remote_lto = LLCP_DEFAULT_LTO;
  
 +      mutex_init(&local->sdreq_lock);
 +      INIT_HLIST_HEAD(&local->pending_sdreqs);
 +      init_timer(&local->sdreq_timer);
 +      local->sdreq_timer.data = (unsigned long) local;
 +      local->sdreq_timer.function = nfc_llcp_sdreq_timer;
 +      INIT_WORK(&local->sdreq_timeout_work, nfc_llcp_sdreq_timeout_work);
 +
        list_add(&local->list, &llcp_devices);
  
        return 0;
diff --combined net/nfc/llcp/sock.c
index 6b3254452b3601db0c97ae51474d7644ae58a629,6c94447ec414c87479581b45fbcced1071f782cb..c1101e6de170fc531a37c1f796242abfbc8c0f64
@@@ -223,124 -223,6 +223,124 @@@ error
        return ret;
  }
  
 +static int nfc_llcp_setsockopt(struct socket *sock, int level, int optname,
 +                             char __user *optval, unsigned int optlen)
 +{
 +      struct sock *sk = sock->sk;
 +      struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
 +      u32 opt;
 +      int err = 0;
 +
 +      pr_debug("%p optname %d\n", sk, optname);
 +
 +      if (level != SOL_NFC)
 +              return -ENOPROTOOPT;
 +
 +      lock_sock(sk);
 +
 +      switch (optname) {
 +      case NFC_LLCP_RW:
 +              if (sk->sk_state == LLCP_CONNECTED ||
 +                  sk->sk_state == LLCP_BOUND ||
 +                  sk->sk_state == LLCP_LISTEN) {
 +                      err = -EINVAL;
 +                      break;
 +              }
 +
 +              if (get_user(opt, (u32 __user *) optval)) {
 +                      err = -EFAULT;
 +                      break;
 +              }
 +
 +              if (opt > LLCP_MAX_RW) {
 +                      err = -EINVAL;
 +                      break;
 +              }
 +
 +              llcp_sock->rw = (u8) opt;
 +
 +              break;
 +
 +      case NFC_LLCP_MIUX:
 +              if (sk->sk_state == LLCP_CONNECTED ||
 +                  sk->sk_state == LLCP_BOUND ||
 +                  sk->sk_state == LLCP_LISTEN) {
 +                      err = -EINVAL;
 +                      break;
 +              }
 +
 +              if (get_user(opt, (u32 __user *) optval)) {
 +                      err = -EFAULT;
 +                      break;
 +              }
 +
 +              if (opt > LLCP_MAX_MIUX) {
 +                      err = -EINVAL;
 +                      break;
 +              }
 +
 +              llcp_sock->miux = (u16) opt;
 +
 +              break;
 +
 +      default:
 +              err = -ENOPROTOOPT;
 +              break;
 +      }
 +
 +      release_sock(sk);
 +
 +      pr_debug("%p rw %d miux %d\n", llcp_sock,
 +               llcp_sock->rw, llcp_sock->miux);
 +
 +      return err;
 +}
 +
 +static int nfc_llcp_getsockopt(struct socket *sock, int level, int optname,
 +                             char __user *optval, int __user *optlen)
 +{
 +      struct sock *sk = sock->sk;
 +      struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
 +      int len, err = 0;
 +
 +      pr_debug("%p optname %d\n", sk, optname);
 +
 +      if (level != SOL_NFC)
 +              return -ENOPROTOOPT;
 +
 +      if (get_user(len, optlen))
 +              return -EFAULT;
 +
 +      len = min_t(u32, len, sizeof(u32));
 +
 +      lock_sock(sk);
 +
 +      switch (optname) {
 +      case NFC_LLCP_RW:
 +              if (put_user(llcp_sock->rw, (u32 __user *) optval))
 +                      err = -EFAULT;
 +
 +              break;
 +
 +      case NFC_LLCP_MIUX:
 +              if (put_user(llcp_sock->miux, (u32 __user *) optval))
 +                      err = -EFAULT;
 +
 +              break;
 +
 +      default:
 +              err = -ENOPROTOOPT;
 +              break;
 +      }
 +
 +      release_sock(sk);
 +
 +      if (put_user(len, optlen))
 +              return -EFAULT;
 +
 +      return err;
 +}
 +
  void nfc_llcp_accept_unlink(struct sock *sk)
  {
        struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
@@@ -388,7 -270,9 +388,9 @@@ struct sock *nfc_llcp_accept_dequeue(st
                }
  
                if (sk->sk_state == LLCP_CONNECTED || !newsock) {
-                       nfc_llcp_accept_unlink(sk);
+                       list_del_init(&lsk->accept_queue);
+                       sock_put(sk);
                        if (newsock)
                                sock_graft(sk, newsock);
  
@@@ -521,8 -405,7 +523,8 @@@ static unsigned int llcp_sock_poll(stru
                return llcp_accept_poll(sk);
  
        if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 -              mask |= POLLERR;
 +              mask |= POLLERR |
 +                      (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
  
        if (!skb_queue_empty(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
@@@ -583,8 -466,6 +585,6 @@@ static int llcp_sock_release(struct soc
                        nfc_llcp_accept_unlink(accept_sk);
  
                        release_sock(accept_sk);
-                       sock_orphan(accept_sk);
                }
        }
  
@@@ -662,7 -543,7 +662,7 @@@ static int llcp_sock_connect(struct soc
  
        llcp_sock->dev = dev;
        llcp_sock->local = nfc_llcp_local_get(local);
 -      llcp_sock->miu = llcp_sock->local->remote_miu;
 +      llcp_sock->remote_miu = llcp_sock->local->remote_miu;
        llcp_sock->ssap = nfc_llcp_get_local_ssap(local);
        if (llcp_sock->ssap == LLCP_SAP_MAX) {
                ret = -ENOMEM;
@@@ -765,6 -646,8 +765,8 @@@ static int llcp_sock_recvmsg(struct kio
  
        pr_debug("%p %zu\n", sk, len);
  
+       msg->msg_namelen = 0;
        lock_sock(sk);
  
        if (sk->sk_state == LLCP_CLOSED &&
  
                pr_debug("Datagram socket %d %d\n", ui_cb->dsap, ui_cb->ssap);
  
+               memset(sockaddr, 0, sizeof(*sockaddr));
                sockaddr->sa_family = AF_NFC;
                sockaddr->nfc_protocol = NFC_PROTO_NFC_DEP;
                sockaddr->dsap = ui_cb->dsap;
@@@ -856,8 -740,8 +859,8 @@@ static const struct proto_ops llcp_sock
        .ioctl          = sock_no_ioctl,
        .listen         = llcp_sock_listen,
        .shutdown       = sock_no_shutdown,
 -      .setsockopt     = sock_no_setsockopt,
 -      .getsockopt     = sock_no_getsockopt,
 +      .setsockopt     = nfc_llcp_setsockopt,
 +      .getsockopt     = nfc_llcp_getsockopt,
        .sendmsg        = llcp_sock_sendmsg,
        .recvmsg        = llcp_sock_recvmsg,
        .mmap           = sock_no_mmap,
@@@ -921,10 -805,8 +924,10 @@@ struct sock *nfc_llcp_sock_alloc(struc
  
        llcp_sock->ssap = 0;
        llcp_sock->dsap = LLCP_SAP_SDP;
 -      llcp_sock->rw = LLCP_DEFAULT_RW;
 -      llcp_sock->miu = LLCP_DEFAULT_MIU;
 +      llcp_sock->rw = LLCP_MAX_RW + 1;
 +      llcp_sock->miux = LLCP_MAX_MIUX + 1;
 +      llcp_sock->remote_rw = LLCP_DEFAULT_RW;
 +      llcp_sock->remote_miu = LLCP_DEFAULT_MIU;
        llcp_sock->send_n = llcp_sock->send_ack_n = 0;
        llcp_sock->recv_n = llcp_sock->recv_ack_n = 0;
        llcp_sock->remote_ready = 1;
diff --combined net/unix/af_unix.c
index 2e4d90044a522c8d357fd6e2d2057061e4154c77,2db702d82e7d16fea7a27a82cc7c5dc3d3d95726..824eaf2c3afa9fa65954f91757d897ca0d289eda
@@@ -1412,8 -1412,8 +1412,8 @@@ static void maybe_add_creds(struct sk_b
        if (UNIXCB(skb).cred)
                return;
        if (test_bit(SOCK_PASSCRED, &sock->flags) ||
-           (other->sk_socket &&
-           test_bit(SOCK_PASSCRED, &other->sk_socket->flags))) {
+           !other->sk_socket ||
+           test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
                UNIXCB(skb).pid  = get_pid(task_tgid(current));
                UNIXCB(skb).cred = get_current_cred();
        }
@@@ -1993,7 -1993,7 +1993,7 @@@ again
                        if ((UNIXCB(skb).pid  != siocb->scm->pid) ||
                            (UNIXCB(skb).cred != siocb->scm->cred))
                                break;
-               } else {
+               } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
                        /* Copy credentials */
                        scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
                        check_creds = 1;
@@@ -2196,9 -2196,7 +2196,9 @@@ static unsigned int unix_dgram_poll(str
  
        /* exceptional events? */
        if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
 -              mask |= POLLERR;
 +              mask |= POLLERR |
 +                      (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 +
        if (sk->sk_shutdown & RCV_SHUTDOWN)
                mask |= POLLRDHUP | POLLIN | POLLRDNORM;
        if (sk->sk_shutdown == SHUTDOWN_MASK)
index 9caa91c0bdafae9395b131cd0c0b56b0bf7cd398,5e04d3d96285daaa01ff8d35e58081ce4807f093..daff75200e256705b3e0e9605cf6e6baf6ac17e3
@@@ -123,14 -123,6 +123,14 @@@ static s32 vmci_transport_error_to_vsoc
        return err > 0 ? -err : err;
  }
  
 +static u32 vmci_transport_peer_rid(u32 peer_cid)
 +{
 +      if (VMADDR_CID_HYPERVISOR == peer_cid)
 +              return VMCI_TRANSPORT_HYPERVISOR_PACKET_RID;
 +
 +      return VMCI_TRANSPORT_PACKET_RID;
 +}
 +
  static inline void
  vmci_transport_packet_init(struct vmci_transport_packet *pkt,
                           struct sockaddr_vm *src,
        pkt->dg.src = vmci_make_handle(VMADDR_CID_ANY,
                                       VMCI_TRANSPORT_PACKET_RID);
        pkt->dg.dst = vmci_make_handle(dst->svm_cid,
 -                                     VMCI_TRANSPORT_PACKET_RID);
 +                                     vmci_transport_peer_rid(dst->svm_cid));
        pkt->dg.payload_size = sizeof(*pkt) - sizeof(pkt->dg);
        pkt->version = VMCI_TRANSPORT_PACKET_VERSION;
        pkt->type = type;
@@@ -516,9 -508,6 +516,9 @@@ static bool vmci_transport_is_trusted(s
  
  static bool vmci_transport_allow_dgram(struct vsock_sock *vsock, u32 peer_cid)
  {
 +      if (VMADDR_CID_HYPERVISOR == peer_cid)
 +              return true;
 +
        if (vsock->cached_peer != peer_cid) {
                vsock->cached_peer = peer_cid;
                if (!vmci_transport_is_trusted(vsock, peer_cid) &&
@@@ -639,6 -628,7 +639,6 @@@ static int vmci_transport_recv_dgram_cb
  static bool vmci_transport_stream_allow(u32 cid, u32 port)
  {
        static const u32 non_socket_contexts[] = {
 -              VMADDR_CID_HYPERVISOR,
                VMADDR_CID_RESERVED,
        };
        int i;
@@@ -677,7 -667,7 +677,7 @@@ static int vmci_transport_recv_stream_c
         */
  
        if (!vmci_transport_stream_allow(dg->src.context, -1)
 -          || VMCI_TRANSPORT_PACKET_RID != dg->src.resource)
 +          || vmci_transport_peer_rid(dg->src.context) != dg->src.resource)
                return VMCI_ERROR_NO_ACCESS;
  
        if (VMCI_DG_SIZE(dg) < sizeof(*pkt))
@@@ -1746,6 -1736,8 +1746,8 @@@ static int vmci_transport_dgram_dequeue
        if (flags & MSG_OOB || flags & MSG_ERRQUEUE)
                return -EOPNOTSUPP;
  
+       msg->msg_namelen = 0;
        /* Retrieve the head sk_buff from the socket's receive queue. */
        err = 0;
        skb = skb_recv_datagram(&vsk->sk, flags, noblock, &err);
        if (err)
                goto out;
  
-       msg->msg_namelen = 0;
        if (msg->msg_name) {
                struct sockaddr_vm *vm_addr;