Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
authorDavid S. Miller <davem@davemloft.net>
Thu, 28 Jan 2010 14:12:38 +0000 (06:12 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Jan 2010 14:12:38 +0000 (06:12 -0800)
18 files changed:
1  2 
MAINTAINERS
drivers/net/benet/be_cmds.c
drivers/net/benet/be_cmds.h
drivers/net/bonding/bond_main.c
drivers/net/e1000/e1000_main.c
drivers/net/e1000e/netdev.c
drivers/net/igb/igb_main.c
drivers/net/igbvf/netdev.c
drivers/net/ixgbe/ixgbe_main.c
drivers/net/qlge/qlge_main.c
drivers/net/sky2.c
drivers/net/starfire.c
drivers/net/tulip/tulip_core.c
drivers/net/virtio_net.c
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/main.c
net/8021q/vlan_dev.c
net/mac80211/driver-trace.h

diff --combined MAINTAINERS
@@@ -2822,10 -2822,11 +2822,11 @@@ L:   netdev@vger.kernel.or
  S:    Maintained
  F:    drivers/net/ixp2000/
  
- INTEL ETHERNET DRIVERS (e100/e1000/e1000e/igb/ixgb/ixgbe)
+ INTEL ETHERNET DRIVERS (e100/e1000/e1000e/igb/igbvf/ixgb/ixgbe)
  M:    Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  M:    Jesse Brandeburg <jesse.brandeburg@intel.com>
  M:    Bruce Allan <bruce.w.allan@intel.com>
+ M:    Alex Duyck <alexander.h.duyck@intel.com>
  M:    PJ Waskiewicz <peter.p.waskiewicz.jr@intel.com>
  M:    John Ronciak <john.ronciak@intel.com>
  L:    e1000-devel@lists.sourceforge.net
@@@ -2835,6 -2836,7 +2836,7 @@@ F:      drivers/net/e100.
  F:    drivers/net/e1000/
  F:    drivers/net/e1000e/
  F:    drivers/net/igb/
+ F:    drivers/net/igbvf/
  F:    drivers/net/ixgb/
  F:    drivers/net/ixgbe/
  
@@@ -4441,13 -4443,6 +4443,13 @@@ S:    Supporte
  F:    Documentation/networking/LICENSE.qla3xxx
  F:    drivers/net/qla3xxx.*
  
 +QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER
 +M:    Amit Kumar Salecha <amit.salecha@qlogic.com>
 +M:    linux-driver@qlogic.com
 +L:    netdev@vger.kernel.org
 +S:    Supported
 +F:    drivers/net/qlcnic/
 +
  QLOGIC QLGE 10Gb ETHERNET DRIVER
  M:    Ron Mercer <ron.mercer@qlogic.com>
  M:    linux-driver@qlogic.com
@@@ -5799,15 -5794,6 +5801,15 @@@ S:    Maintaine
  F:    Documentation/filesystems/vfat.txt
  F:    fs/fat/
  
 +VIRTIO HOST (VHOST)
 +M:    "Michael S. Tsirkin" <mst@redhat.com>
 +L:    kvm@vger.kernel.org
 +L:    virtualization@lists.osdl.org
 +L:    netdev@vger.kernel.org
 +S:    Maintained
 +F:    drivers/vhost/
 +F:    include/linux/vhost.h
 +
  VIA RHINE NETWORK DRIVER
  M:    Roger Luethi <rl@hellgate.ch>
  S:    Maintained
@@@ -286,7 -286,7 +286,7 @@@ static void be_wrb_hdr_prepare(struct b
                                MCC_WRB_SGE_CNT_SHIFT;
        wrb->payload_length = payload_len;
        wrb->tag0 = opcode;
-       be_dws_cpu_to_le(wrb, 20);
+       be_dws_cpu_to_le(wrb, 8);
  }
  
  /* Don't touch the hdr after it's prepared */
        spin_unlock_bh(&adapter->mcc_lock);
        return status;
  }
 +
 +extern int be_cmd_get_seeprom_data(struct be_adapter *adapter,
 +                              struct be_dma_mem *nonemb_cmd)
 +{
 +      struct be_mcc_wrb *wrb;
 +      struct be_cmd_req_seeprom_read *req;
 +      struct be_sge *sge;
 +      int status;
 +
 +      spin_lock_bh(&adapter->mcc_lock);
 +
 +      wrb = wrb_from_mccq(adapter);
 +      req = nonemb_cmd->va;
 +      sge = nonembedded_sgl(wrb);
 +
 +      be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1,
 +                      OPCODE_COMMON_SEEPROM_READ);
 +
 +      be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
 +                      OPCODE_COMMON_SEEPROM_READ, sizeof(*req));
 +
 +      sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
 +      sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
 +      sge->len = cpu_to_le32(nonemb_cmd->size);
 +
 +      status = be_mcc_notify_wait(adapter);
 +
 +      spin_unlock_bh(&adapter->mcc_lock);
 +      return status;
 +}
@@@ -124,7 -124,6 +124,7 @@@ struct be_mcc_mailbox 
  #define OPCODE_COMMON_CQ_CREATE                               12
  #define OPCODE_COMMON_EQ_CREATE                               13
  #define OPCODE_COMMON_MCC_CREATE                      21
 +#define OPCODE_COMMON_SEEPROM_READ                    30
  #define OPCODE_COMMON_NTWK_RX_FILTER                  34
  #define OPCODE_COMMON_GET_FW_VERSION                  35
  #define OPCODE_COMMON_SET_FLOW_CONTROL                        36
@@@ -165,7 -164,8 +165,8 @@@ struct be_cmd_req_hdr 
        u8 domain;              /* dword 0 */
        u32 timeout;            /* dword 1 */
        u32 request_length;     /* dword 2 */
-       u32 rsvd;               /* dword 3 */
+       u8 version;             /* dword 3 */
+       u8 rsvd[3];             /* dword 3 */
  };
  
  #define RESP_HDR_INFO_OPCODE_SHIFT    0       /* bits 0 - 7 */
@@@ -855,19 -855,6 +856,19 @@@ struct be_cmd_resp_ddrdma_test 
        u8  rcv_buff[4096];
  };
  
 +/*********************** SEEPROM Read ***********************/
 +
 +#define BE_READ_SEEPROM_LEN 1024
 +struct be_cmd_req_seeprom_read {
 +      struct be_cmd_req_hdr hdr;
 +      u8 rsvd0[BE_READ_SEEPROM_LEN];
 +};
 +
 +struct be_cmd_resp_seeprom_read {
 +      struct be_cmd_req_hdr hdr;
 +      u8 seeprom_data[BE_READ_SEEPROM_LEN];
 +};
 +
  extern int be_pci_fnum_get(struct be_adapter *adapter);
  extern int be_cmd_POST(struct be_adapter *adapter);
  extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
@@@ -940,8 -927,5 +941,8 @@@ extern int be_cmd_loopback_test(struct 
                                u32 num_pkts, u64 pattern);
  extern int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern,
                        u32 byte_cnt, struct be_dma_mem *cmd);
 +extern int be_cmd_get_seeprom_data(struct be_adapter *adapter,
 +                              struct be_dma_mem *nonemb_cmd);
  extern int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
                                u8 loopback_type, u8 enable);
 +
@@@ -2615,17 -2615,6 +2615,17 @@@ static int bond_arp_rcv(struct sk_buff 
        unsigned char *arp_ptr;
        __be32 sip, tip;
  
 +      if (dev->priv_flags & IFF_802_1Q_VLAN) {
 +              /*
 +               * When using VLANS and bonding, dev and oriv_dev may be
 +               * incorrect if the physical interface supports VLAN
 +               * acceleration.  With this change ARP validation now
 +               * works for hosts only reachable on the VLAN interface.
 +               */
 +              dev = vlan_dev_real_dev(dev);
 +              orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif);
 +      }
 +
        if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER))
                goto out;
  
@@@ -3307,7 -3296,7 +3307,7 @@@ static void bond_remove_proc_entry(stru
  /* Create the bonding directory under /proc/net, if doesn't exist yet.
   * Caller must hold rtnl_lock.
   */
 -static void bond_create_proc_dir(struct bond_net *bn)
 +static void __net_init bond_create_proc_dir(struct bond_net *bn)
  {
        if (!bn->proc_dir) {
                bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net);
  /* Destroy the bonding directory under /proc/net, if empty.
   * Caller must hold rtnl_lock.
   */
 -static void bond_destroy_proc_dir(struct bond_net *bn)
 +static void __net_exit bond_destroy_proc_dir(struct bond_net *bn)
  {
        if (bn->proc_dir) {
                remove_proc_entry(DRV_NAME, bn->net->proc_net);
@@@ -3338,11 -3327,11 +3338,11 @@@ static void bond_remove_proc_entry(stru
  {
  }
  
 -static void bond_create_proc_dir(struct bond_net *bn)
 +static inline void bond_create_proc_dir(struct bond_net *bn)
  {
  }
  
 -static void bond_destroy_proc_dir(struct bond_net *bn)
 +static inline void bond_destroy_proc_dir(struct bond_net *bn)
  {
  }
  
@@@ -3650,7 -3639,7 +3650,7 @@@ static int bond_open(struct net_device 
                 */
                if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB))) {
                        /* something went wrong - fail the open operation */
-                       return -1;
+                       return -ENOMEM;
                }
  
                INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor);
@@@ -4955,7 -4944,7 +4955,7 @@@ out_netdev
        goto out;
  }
  
 -static int bond_net_init(struct net *net)
 +static int __net_init bond_net_init(struct net *net)
  {
        struct bond_net *bn = net_generic(net, bond_net_id);
  
        return 0;
  }
  
 -static void bond_net_exit(struct net *net)
 +static void __net_exit bond_net_exit(struct net *net)
  {
        struct bond_net *bn = net_generic(net, bond_net_id);
  
@@@ -42,7 -42,7 +42,7 @@@ static const char e1000_copyright[] = "
   * Macro expands to...
   *   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
   */
 -static struct pci_device_id e1000_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
        INTEL_E1000_ETHERNET_DEVICE(0x1000),
        INTEL_E1000_ETHERNET_DEVICE(0x1001),
        INTEL_E1000_ETHERNET_DEVICE(0x1004),
@@@ -1698,18 -1698,6 +1698,6 @@@ static void e1000_setup_rctl(struct e10
        rctl &= ~E1000_RCTL_SZ_4096;
        rctl |= E1000_RCTL_BSEX;
        switch (adapter->rx_buffer_len) {
-               case E1000_RXBUFFER_256:
-                       rctl |= E1000_RCTL_SZ_256;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
-               case E1000_RXBUFFER_512:
-                       rctl |= E1000_RCTL_SZ_512;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
-               case E1000_RXBUFFER_1024:
-                       rctl |= E1000_RCTL_SZ_1024;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
                case E1000_RXBUFFER_2048:
                default:
                        rctl |= E1000_RCTL_SZ_2048;
@@@ -2139,7 -2127,7 +2127,7 @@@ static void e1000_set_rx_mode(struct ne
                        rctl |= E1000_RCTL_VFE;
        }
  
 -      if (netdev->uc.count > rar_entries - 1) {
 +      if (netdev_uc_count(netdev) > rar_entries - 1) {
                rctl |= E1000_RCTL_UPE;
        } else if (!(netdev->flags & IFF_PROMISC)) {
                rctl &= ~E1000_RCTL_UPE;
         */
        i = 1;
        if (use_uc)
 -              list_for_each_entry(ha, &netdev->uc.list, list) {
 +              netdev_for_each_uc_addr(ha, netdev) {
                        if (i == rar_entries)
                                break;
                        e1000_rar_set(hw, ha->addr, i++);
@@@ -3176,13 -3164,7 +3164,7 @@@ static int e1000_change_mtu(struct net_
         *  however with the new *_jumbo_rx* routines, jumbo receives will use
         *  fragmented skbs */
  
-       if (max_frame <= E1000_RXBUFFER_256)
-               adapter->rx_buffer_len = E1000_RXBUFFER_256;
-       else if (max_frame <= E1000_RXBUFFER_512)
-               adapter->rx_buffer_len = E1000_RXBUFFER_512;
-       else if (max_frame <= E1000_RXBUFFER_1024)
-               adapter->rx_buffer_len = E1000_RXBUFFER_1024;
-       else if (max_frame <= E1000_RXBUFFER_2048)
+       if (max_frame <= E1000_RXBUFFER_2048)
                adapter->rx_buffer_len = E1000_RXBUFFER_2048;
        else
  #if (PAGE_SIZE >= E1000_RXBUFFER_16384)
@@@ -2350,18 -2350,6 +2350,6 @@@ static void e1000_setup_rctl(struct e10
        rctl &= ~E1000_RCTL_SZ_4096;
        rctl |= E1000_RCTL_BSEX;
        switch (adapter->rx_buffer_len) {
-       case 256:
-               rctl |= E1000_RCTL_SZ_256;
-               rctl &= ~E1000_RCTL_BSEX;
-               break;
-       case 512:
-               rctl |= E1000_RCTL_SZ_512;
-               rctl &= ~E1000_RCTL_BSEX;
-               break;
-       case 1024:
-               rctl |= E1000_RCTL_SZ_1024;
-               rctl &= ~E1000_RCTL_BSEX;
-               break;
        case 2048:
        default:
                rctl |= E1000_RCTL_SZ_2048;
@@@ -2553,14 -2541,22 +2541,14 @@@ static void e1000_configure_rx(struct e
   *  @hw: pointer to the HW structure
   *  @mc_addr_list: array of multicast addresses to program
   *  @mc_addr_count: number of multicast addresses to program
 - *  @rar_used_count: the first RAR register free to program
 - *  @rar_count: total number of supported Receive Address Registers
   *
 - *  Updates the Receive Address Registers and Multicast Table Array.
 + *  Updates the Multicast Table Array.
   *  The caller must have a packed mc_addr_list of multicast addresses.
 - *  The parameter rar_count will usually be hw->mac.rar_entry_count
 - *  unless there are workarounds that change this.  Currently no func pointer
 - *  exists and all implementations are handled in the generic version of this
 - *  function.
   **/
  static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
 -                                    u32 mc_addr_count, u32 rar_used_count,
 -                                    u32 rar_count)
 +                                    u32 mc_addr_count)
  {
 -      hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count,
 -                                      rar_used_count, rar_count);
 +      hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count);
  }
  
  /**
@@@ -2576,6 -2572,7 +2564,6 @@@ static void e1000_set_multi(struct net_
  {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 -      struct e1000_mac_info *mac = &hw->mac;
        struct dev_mc_list *mc_ptr;
        u8  *mta_list;
        u32 rctl;
                        mc_ptr = mc_ptr->next;
                }
  
 -              e1000_update_mc_addr_list(hw, mta_list, i, 1,
 -                                        mac->rar_entry_count);
 +              e1000_update_mc_addr_list(hw, mta_list, i);
                kfree(mta_list);
        } else {
                /*
                 * if we're called from probe, we might not have
                 * anything to do here, so clear out the list
                 */
 -              e1000_update_mc_addr_list(hw, NULL, 0, 1, mac->rar_entry_count);
 +              e1000_update_mc_addr_list(hw, NULL, 0);
        }
  }
  
@@@ -3788,7 -3786,7 +3776,7 @@@ static int e1000_tso(struct e1000_adapt
                                                         0, IPPROTO_TCP, 0);
                cmd_length = E1000_TXD_CMD_IP;
                ipcse = skb_transport_offset(skb) - 1;
-       } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
+       } else if (skb_is_gso_v6(skb)) {
                ipv6_hdr(skb)->payload_len = 0;
                tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
                                                       &ipv6_hdr(skb)->daddr,
@@@ -4324,13 -4322,7 +4312,7 @@@ static int e1000_change_mtu(struct net_
         * fragmented skbs
         */
  
-       if (max_frame <= 256)
-               adapter->rx_buffer_len = 256;
-       else if (max_frame <= 512)
-               adapter->rx_buffer_len = 512;
-       else if (max_frame <= 1024)
-               adapter->rx_buffer_len = 1024;
-       else if (max_frame <= 2048)
+       if (max_frame <= 2048)
                adapter->rx_buffer_len = 2048;
        else
                adapter->rx_buffer_len = 4096;
@@@ -5142,7 -5134,7 +5124,7 @@@ static int __devinit e1000_probe(struc
  
        e1000_eeprom_checks(adapter);
  
 -      /* copy the MAC address out of the NVM */
 +      /* copy the MAC address */
        if (e1000e_read_mac_addr(&adapter->hw))
                e_err("NVM Read Error while reading MAC address\n");
  
@@@ -5334,7 -5326,7 +5316,7 @@@ static struct pci_error_handlers e1000_
        .resume = e1000_io_resume,
  };
  
 -static struct pci_device_id e1000_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },
@@@ -60,7 -60,7 +60,7 @@@ static const struct e1000_info *igb_inf
        [board_82575] = &e1000_82575_info,
  };
  
 -static struct pci_device_id igb_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_FIBER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SERDES), board_82575 },
@@@ -2905,13 -2905,12 +2905,13 @@@ static int igb_write_uc_addr_list(struc
        int count = 0;
  
        /* return ENOMEM indicating insufficient memory for addresses */
 -      if (netdev->uc.count > rar_entries)
 +      if (netdev_uc_count(netdev) > rar_entries)
                return -ENOMEM;
  
 -      if (netdev->uc.count && rar_entries) {
 +      if (!netdev_uc_empty(netdev) && rar_entries) {
                struct netdev_hw_addr *ha;
 -              list_for_each_entry(ha, &netdev->uc.list, list) {
 +
 +              netdev_for_each_uc_addr(ha, netdev) {
                        if (!rar_entries)
                                break;
                        igb_rar_set_qsel(adapter, ha->addr,
@@@ -3423,7 -3422,7 +3423,7 @@@ static inline int igb_tso_adv(struct ig
                                                         iph->daddr, 0,
                                                         IPPROTO_TCP,
                                                         0);
-       } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
+       } else if (skb_is_gso_v6(skb)) {
                ipv6_hdr(skb)->payload_len = 0;
                tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
                                                       &ipv6_hdr(skb)->daddr,
@@@ -3585,6 -3584,7 +3585,7 @@@ static inline int igb_tx_map_adv(struc
        for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
                struct skb_frag_struct *frag;
  
+               count++;
                i++;
                if (i == tx_ring->count)
                        i = 0;
                if (pci_dma_mapping_error(pdev, buffer_info->dma))
                        goto dma_error;
  
-               count++;
        }
  
        tx_ring->buffer_info[i].skb = skb;
@@@ -4106,9 -4105,6 +4106,9 @@@ static irqreturn_t igb_msix_other(int i
        u32 icr = rd32(E1000_ICR);
        /* reading ICR causes bit 31 of EICR to be cleared */
  
 +      if (icr & E1000_ICR_DRSTA)
 +              schedule_work(&adapter->reset_task);
 +
        if (icr & E1000_ICR_DOUTSYNC) {
                /* HW is reporting DMA is out of sync */
                adapter->stats.doosync++;
@@@ -4732,9 -4728,6 +4732,9 @@@ static irqreturn_t igb_intr_msi(int irq
  
        igb_write_itr(q_vector);
  
 +      if (icr & E1000_ICR_DRSTA)
 +              schedule_work(&adapter->reset_task);
 +
        if (icr & E1000_ICR_DOUTSYNC) {
                /* HW is reporting DMA is out of sync */
                adapter->stats.doosync++;
@@@ -4774,9 -4767,6 +4774,9 @@@ static irqreturn_t igb_intr(int irq, vo
        if (!(icr & E1000_ICR_INT_ASSERTED))
                return IRQ_NONE;
  
 +      if (icr & E1000_ICR_DRSTA)
 +              schedule_work(&adapter->reset_task);
 +
        if (icr & E1000_ICR_DOUTSYNC) {
                /* HW is reporting DMA is out of sync */
                adapter->stats.doosync++;
@@@ -1963,7 -1963,7 +1963,7 @@@ static int igbvf_tso(struct igbvf_adapt
                                                         iph->daddr, 0,
                                                         IPPROTO_TCP,
                                                         0);
-       } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
+       } else if (skb_is_gso_v6(skb)) {
                ipv6_hdr(skb)->payload_len = 0;
                tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
                                                       &ipv6_hdr(skb)->daddr,
@@@ -2117,6 -2117,7 +2117,7 @@@ static inline int igbvf_tx_map_adv(stru
        /* set time_stamp *before* dma to help avoid a possible race */
        buffer_info->time_stamp = jiffies;
        buffer_info->next_to_watch = i;
+       buffer_info->mapped_as_page = false;
        buffer_info->dma = pci_map_single(pdev, skb->data, len,
                                          PCI_DMA_TODEVICE);
        if (pci_dma_mapping_error(pdev, buffer_info->dma))
        for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
                struct skb_frag_struct *frag;
  
+               count++;
                i++;
                if (i == tx_ring->count)
                        i = 0;
                                                PCI_DMA_TODEVICE);
                if (pci_dma_mapping_error(pdev, buffer_info->dma))
                        goto dma_error;
-               count++;
        }
  
        tx_ring->buffer_info[i].skb = skb;
@@@ -2608,7 -2609,11 +2609,7 @@@ static void igbvf_print_device_info(str
        struct pci_dev *pdev = adapter->pdev;
  
        dev_info(&pdev->dev, "Intel(R) 82576 Virtual Function\n");
 -      dev_info(&pdev->dev, "Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
 -               /* MAC address */
 -               netdev->dev_addr[0], netdev->dev_addr[1],
 -               netdev->dev_addr[2], netdev->dev_addr[3],
 -               netdev->dev_addr[4], netdev->dev_addr[5]);
 +      dev_info(&pdev->dev, "Address: %pM\n", netdev->dev_addr);
        dev_info(&pdev->dev, "MAC: %d\n", hw->mac.type);
  }
  
@@@ -2774,8 -2779,11 +2775,8 @@@ static int __devinit igbvf_probe(struc
        memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
  
        if (!is_valid_ether_addr(netdev->perm_addr)) {
 -              dev_err(&pdev->dev, "Invalid MAC Address: "
 -                      "%02x:%02x:%02x:%02x:%02x:%02x\n",
 -                      netdev->dev_addr[0], netdev->dev_addr[1],
 -                      netdev->dev_addr[2], netdev->dev_addr[3],
 -                      netdev->dev_addr[4], netdev->dev_addr[5]);
 +              dev_err(&pdev->dev, "Invalid MAC Address: %pM\n",
 +                      netdev->dev_addr);
                err = -EIO;
                goto err_hw_init;
        }
@@@ -2877,7 -2885,7 +2878,7 @@@ static struct pci_error_handlers igbvf_
        .resume = igbvf_io_resume,
  };
  
 -static struct pci_device_id igbvf_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(igbvf_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_VF), board_vf },
        { } /* terminate list */
  };
@@@ -45,7 -45,6 +45,7 @@@
  #include "ixgbe.h"
  #include "ixgbe_common.h"
  #include "ixgbe_dcb_82599.h"
 +#include "ixgbe_sriov.h"
  
  char ixgbe_driver_name[] = "ixgbe";
  static const char ixgbe_driver_string[] =
@@@ -68,7 -67,7 +68,7 @@@ static const struct ixgbe_info *ixgbe_i
   * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
   *   Class, Class Mask, private data (not used) }
   */
 -static struct pci_device_id ixgbe_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(ixgbe_pci_tbl) = {
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598),
         board_82598 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_DUAL_PORT),
@@@ -125,13 -124,6 +125,13 @@@ static struct notifier_block dca_notifi
  };
  #endif
  
 +#ifdef CONFIG_PCI_IOV
 +static unsigned int max_vfs;
 +module_param(max_vfs, uint, 0);
 +MODULE_PARM_DESC(max_vfs, "Maximum number of virtual functions to allocate "
 +                 "per physical function");
 +#endif /* CONFIG_PCI_IOV */
 +
  MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
  MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");
  MODULE_LICENSE("GPL");
@@@ -139,41 -131,6 +139,41 @@@ MODULE_VERSION(DRV_VERSION)
  
  #define DEFAULT_DEBUG_LEVEL_SHIFT 3
  
 +static inline void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
 +{
 +      struct ixgbe_hw *hw = &adapter->hw;
 +      u32 gcr;
 +      u32 gpie;
 +      u32 vmdctl;
 +
 +#ifdef CONFIG_PCI_IOV
 +      /* disable iov and allow time for transactions to clear */
 +      pci_disable_sriov(adapter->pdev);
 +#endif
 +
 +      /* turn off device IOV mode */
 +      gcr = IXGBE_READ_REG(hw, IXGBE_GCR_EXT);
 +      gcr &= ~(IXGBE_GCR_EXT_SRIOV);
 +      IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, gcr);
 +      gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
 +      gpie &= ~IXGBE_GPIE_VTMODE_MASK;
 +      IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
 +
 +      /* set default pool back to 0 */
 +      vmdctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
 +      vmdctl &= ~IXGBE_VT_CTL_POOL_MASK;
 +      IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vmdctl);
 +
 +      /* take a breather then clean up driver data */
 +      msleep(100);
 +      if (adapter->vfinfo)
 +              kfree(adapter->vfinfo);
 +      adapter->vfinfo = NULL;
 +
 +      adapter->num_vfs = 0;
 +      adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
 +}
 +
  static void ixgbe_release_hw_control(struct ixgbe_adapter *adapter)
  {
        u32 ctrl_ext;
@@@ -1068,12 -1025,7 +1068,12 @@@ static void ixgbe_configure_msix(struc
  
        /* set up to autoclear timer, and the vectors */
        mask = IXGBE_EIMS_ENABLE_MASK;
 -      mask &= ~(IXGBE_EIMS_OTHER | IXGBE_EIMS_LSC);
 +      if (adapter->num_vfs)
 +              mask &= ~(IXGBE_EIMS_OTHER |
 +                        IXGBE_EIMS_MAILBOX |
 +                        IXGBE_EIMS_LSC);
 +      else
 +              mask &= ~(IXGBE_EIMS_OTHER | IXGBE_EIMS_LSC);
        IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIAC, mask);
  }
  
@@@ -1302,9 -1254,6 +1302,9 @@@ static irqreturn_t ixgbe_msix_lsc(int i
        if (eicr & IXGBE_EICR_LSC)
                ixgbe_check_lsc(adapter);
  
 +      if (eicr & IXGBE_EICR_MAILBOX)
 +              ixgbe_msg_task(adapter);
 +
        if (hw->mac.type == ixgbe_mac_82598EB)
                ixgbe_check_fan_failure(adapter, eicr);
  
@@@ -1819,8 -1768,6 +1819,8 @@@ static inline void ixgbe_irq_enable(str
                mask |= IXGBE_EIMS_ECC;
                mask |= IXGBE_EIMS_GPI_SDP1;
                mask |= IXGBE_EIMS_GPI_SDP2;
 +              if (adapter->num_vfs)
 +                      mask |= IXGBE_EIMS_MAILBOX;
        }
        if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
            adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)
        IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
        ixgbe_irq_enable_queues(adapter, ~0);
        IXGBE_WRITE_FLUSH(&adapter->hw);
 +
 +      if (adapter->num_vfs > 32) {
 +              u32 eitrsel = (1 << (adapter->num_vfs - 32)) - 1;
 +              IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITRSEL, eitrsel);
 +      }
  }
  
  /**
@@@ -1963,8 -1905,6 +1963,8 @@@ static inline void ixgbe_irq_disable(st
                IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, 0xFFFF0000);
                IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), ~0);
                IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1), ~0);
 +              if (adapter->num_vfs > 32)
 +                      IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITRSEL, 0);
        }
        IXGBE_WRITE_FLUSH(&adapter->hw);
        if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
@@@ -2049,32 -1989,18 +2049,32 @@@ static void ixgbe_configure_tx(struct i
  
        if (hw->mac.type == ixgbe_mac_82599EB) {
                u32 rttdcs;
 +              u32 mask;
  
                /* disable the arbiter while setting MTQC */
                rttdcs = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
                rttdcs |= IXGBE_RTTDCS_ARBDIS;
                IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, rttdcs);
  
 -              /* We enable 8 traffic classes, DCB only */
 -              if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
 -                      IXGBE_WRITE_REG(hw, IXGBE_MTQC, (IXGBE_MTQC_RT_ENA |
 -                                      IXGBE_MTQC_8TC_8TQ));
 -              else
 +              /* set transmit pool layout */
 +              mask = (IXGBE_FLAG_SRIOV_ENABLED | IXGBE_FLAG_DCB_ENABLED);
 +              switch (adapter->flags & mask) {
 +
 +              case (IXGBE_FLAG_SRIOV_ENABLED):
 +                      IXGBE_WRITE_REG(hw, IXGBE_MTQC,
 +                                      (IXGBE_MTQC_VT_ENA | IXGBE_MTQC_64VF));
 +                      break;
 +
 +              case (IXGBE_FLAG_DCB_ENABLED):
 +                      /* We enable 8 traffic classes, DCB only */
 +                      IXGBE_WRITE_REG(hw, IXGBE_MTQC,
 +                                    (IXGBE_MTQC_RT_ENA | IXGBE_MTQC_8TC_8TQ));
 +                      break;
 +
 +              default:
                        IXGBE_WRITE_REG(hw, IXGBE_MTQC, IXGBE_MTQC_64Q_1PB);
 +                      break;
 +              }
  
                /* re-eable the arbiter */
                rttdcs &= ~IXGBE_RTTDCS_ARBDIS;
@@@ -2133,16 -2059,12 +2133,16 @@@ static u32 ixgbe_setup_mrqc(struct ixgb
  #ifdef CONFIG_IXGBE_DCB
                                 | IXGBE_FLAG_DCB_ENABLED
  #endif
 +                               | IXGBE_FLAG_SRIOV_ENABLED
                                );
  
        switch (mask) {
        case (IXGBE_FLAG_RSS_ENABLED):
                mrqc = IXGBE_MRQC_RSSEN;
                break;
 +      case (IXGBE_FLAG_SRIOV_ENABLED):
 +              mrqc = IXGBE_MRQC_VMDQEN;
 +              break;
  #ifdef CONFIG_IXGBE_DCB
        case (IXGBE_FLAG_DCB_ENABLED):
                mrqc = IXGBE_MRQC_RT8TCEN;
@@@ -2223,9 -2145,7 +2223,9 @@@ static void ixgbe_configure_rx(struct i
        int rx_buf_len;
  
        /* Decide whether to use packet split mode or not */
 -      adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED;
 +      /* Do not use packet split if we're in SR-IOV Mode */
 +      if (!adapter->num_vfs)
 +              adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED;
  
        /* Set the RX buffer length according to the mode */
        if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
                                      IXGBE_PSRTYPE_IPV4HDR |
                                      IXGBE_PSRTYPE_IPV6HDR |
                                      IXGBE_PSRTYPE_L2HDR;
 -                      IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), psrtype);
 +                      IXGBE_WRITE_REG(hw,
 +                                      IXGBE_PSRTYPE(adapter->num_vfs),
 +                                      psrtype);
                }
        } else {
                if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) &&
                IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
        }
  
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
 +              u32 vt_reg_bits;
 +              u32 reg_offset, vf_shift;
 +              u32 vmdctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
 +              vt_reg_bits = IXGBE_VMD_CTL_VMDQ_EN
 +                      | IXGBE_VT_CTL_REPLEN;
 +              vt_reg_bits |= (adapter->num_vfs <<
 +                              IXGBE_VT_CTL_POOL_SHIFT);
 +              IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vmdctl | vt_reg_bits);
 +              IXGBE_WRITE_REG(hw, IXGBE_MRQC, 0);
 +
 +              vf_shift = adapter->num_vfs % 32;
 +              reg_offset = adapter->num_vfs / 32;
 +              IXGBE_WRITE_REG(hw, IXGBE_VFRE(0), 0);
 +              IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), 0);
 +              IXGBE_WRITE_REG(hw, IXGBE_VFTE(0), 0);
 +              IXGBE_WRITE_REG(hw, IXGBE_VFTE(1), 0);
 +              /* Enable only the PF's pool for Tx/Rx */
 +              IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), (1 << vf_shift));
 +              IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset), (1 << vf_shift));
 +              IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
 +              ixgbe_set_vmolr(hw, adapter->num_vfs);
 +      }
 +
        /* Program MRQC for the distribution of queues */
        mrqc = ixgbe_setup_mrqc(adapter);
  
        }
        IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
  
 +      if (adapter->num_vfs) {
 +              u32 reg;
 +
 +              /* Map PF MAC address in RAR Entry 0 to first pool
 +               * following VFs */
 +              hw->mac.ops.set_vmdq(hw, 0, adapter->num_vfs);
 +
 +              /* Set up VF register offsets for selected VT Mode, i.e.
 +               * 64 VFs for SR-IOV */
 +              reg = IXGBE_READ_REG(hw, IXGBE_GCR_EXT);
 +              reg |= IXGBE_GCR_EXT_SRIOV;
 +              IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, reg);
 +      }
 +
        rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
  
        if (adapter->flags & IXGBE_FLAG_RSS_ENABLED ||
@@@ -2432,17 -2312,15 +2432,17 @@@ static void ixgbe_vlan_rx_add_vid(struc
  {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        struct ixgbe_hw *hw = &adapter->hw;
 +      int pool_ndx = adapter->num_vfs;
  
        /* add VID to filter table */
 -      hw->mac.ops.set_vfta(&adapter->hw, vid, 0, true);
 +      hw->mac.ops.set_vfta(&adapter->hw, vid, pool_ndx, true);
  }
  
  static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
  {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        struct ixgbe_hw *hw = &adapter->hw;
 +      int pool_ndx = adapter->num_vfs;
  
        if (!test_bit(__IXGBE_DOWN, &adapter->state))
                ixgbe_irq_disable(adapter);
                ixgbe_irq_enable(adapter);
  
        /* remove VID from filter table */
 -      hw->mac.ops.set_vfta(&adapter->hw, vid, 0, false);
 +      hw->mac.ops.set_vfta(&adapter->hw, vid, pool_ndx, false);
  }
  
  static void ixgbe_vlan_rx_register(struct net_device *netdev,
@@@ -2536,7 -2414,7 +2536,7 @@@ static u8 *ixgbe_addr_list_itr(struct i
   * responsible for configuring the hardware for proper unicast, multicast and
   * promiscuous mode.
   **/
 -static void ixgbe_set_rx_mode(struct net_device *netdev)
 +void ixgbe_set_rx_mode(struct net_device *netdev)
  {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        struct ixgbe_hw *hw = &adapter->hw;
        IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
  
        /* reprogram secondary unicast list */
 -      hw->mac.ops.update_uc_addr_list(hw, &netdev->uc.list);
 +      hw->mac.ops.update_uc_addr_list(hw, netdev);
  
        /* reprogram multicast list */
        addr_count = netdev->mc_count;
                addr_list = netdev->mc_list->dmi_addr;
        hw->mac.ops.update_mc_addr_list(hw, addr_list, addr_count,
                                        ixgbe_addr_list_itr);
 +      if (adapter->num_vfs)
 +              ixgbe_restore_vf_multicasts(adapter);
  }
  
  static void ixgbe_napi_enable_all(struct ixgbe_adapter *adapter)
@@@ -2826,7 -2702,6 +2826,7 @@@ static int ixgbe_up_complete(struct ixg
        u32 txdctl, rxdctl, mhadd;
        u32 dmatxctl;
        u32 gpie;
 +      u32 ctrl_ext;
  
        ixgbe_get_hw_control(adapter);
  
                        /* MSI only */
                        gpie = 0;
                }
 +              if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
 +                      gpie &= ~IXGBE_GPIE_VTMODE_MASK;
 +                      gpie |= IXGBE_GPIE_VTMODE_64;
 +              }
                /* XXX: to interrupt immediately for EICS writes, enable this */
                /* gpie |= IXGBE_GPIE_EIMEN; */
                IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
                txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(j));
                txdctl |= IXGBE_TXDCTL_ENABLE;
                IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(j), txdctl);
 +              if (hw->mac.type == ixgbe_mac_82599EB) {
 +                      int wait_loop = 10;
 +                      /* poll for Tx Enable ready */
 +                      do {
 +                              msleep(1);
 +                              txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(j));
 +                      } while (--wait_loop &&
 +                               !(txdctl & IXGBE_TXDCTL_ENABLE));
 +                      if (!wait_loop)
 +                              DPRINTK(DRV, ERR, "Could not enable "
 +                                      "Tx Queue %d\n", j);
 +              }
        }
  
        for (i = 0; i < num_rx_rings; i++) {
        adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
        adapter->link_check_timeout = jiffies;
        mod_timer(&adapter->watchdog_timer, jiffies);
 +
 +      /* Set PF Reset Done bit so PF/VF Mail Ops can work */
 +      ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
 +      ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
 +      IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
 +
        return 0;
  }
  
@@@ -3070,8 -2923,7 +3070,8 @@@ void ixgbe_reset(struct ixgbe_adapter *
        }
  
        /* reprogram the RAR[0] in case user changed it. */
 -      hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 +      hw->mac.ops.set_rar(hw, 0, hw->mac.addr, adapter->num_vfs,
 +                          IXGBE_RAH_AV);
  }
  
  /**
@@@ -3203,17 -3055,6 +3203,17 @@@ void ixgbe_down(struct ixgbe_adapter *a
        /* signal that we are down to the interrupt handler */
        set_bit(__IXGBE_DOWN, &adapter->state);
  
 +      /* disable receive for all VFs and wait one second */
 +      if (adapter->num_vfs) {
 +              for (i = 0 ; i < adapter->num_vfs; i++)
 +                      adapter->vfinfo[i].clear_to_send = 0;
 +
 +              /* ping all the active vfs to let them know we are going down */
 +              ixgbe_ping_all_vfs(adapter);
 +              /* Disable all VFTE/VFRE TX/RX */
 +              ixgbe_disable_tx_rx(adapter);
 +      }
 +
        /* disable receives */
        rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
        IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN);
@@@ -3450,19 -3291,6 +3450,19 @@@ static inline bool ixgbe_set_fcoe_queue
  }
  
  #endif /* IXGBE_FCOE */
 +/**
 + * ixgbe_set_sriov_queues: Allocate queues for IOV use
 + * @adapter: board private structure to initialize
 + *
 + * IOV doesn't actually use anything, so just NAK the
 + * request for now and let the other queue routines
 + * figure out what to do.
 + */
 +static inline bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
 +{
 +      return false;
 +}
 +
  /*
   * ixgbe_set_num_queues: Allocate queues for device, feature dependant
   * @adapter: board private structure to initialize
   **/
  static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
  {
 +      /* Start with base case */
 +      adapter->num_rx_queues = 1;
 +      adapter->num_tx_queues = 1;
 +      adapter->num_rx_pools = adapter->num_rx_queues;
 +      adapter->num_rx_queues_per_pool = 1;
 +
 +      if (ixgbe_set_sriov_queues(adapter))
 +              return;
 +
  #ifdef IXGBE_FCOE
        if (ixgbe_set_fcoe_queues(adapter))
                goto done;
@@@ -3756,24 -3575,6 +3756,24 @@@ static inline bool ixgbe_cache_ring_fco
  
  #endif /* IXGBE_FCOE */
  /**
 + * ixgbe_cache_ring_sriov - Descriptor ring to register mapping for sriov
 + * @adapter: board private structure to initialize
 + *
 + * SR-IOV doesn't use any descriptor rings but changes the default if
 + * no other mapping is used.
 + *
 + */
 +static inline bool ixgbe_cache_ring_sriov(struct ixgbe_adapter *adapter)
 +{
 +      adapter->rx_ring[0].reg_idx = adapter->num_vfs * 2;
 +      adapter->tx_ring[0].reg_idx = adapter->num_vfs * 2;
 +      if (adapter->num_vfs)
 +              return true;
 +      else
 +              return false;
 +}
 +
 +/**
   * ixgbe_cache_ring_register - Descriptor ring to register mapping
   * @adapter: board private structure to initialize
   *
@@@ -3790,9 -3591,6 +3790,9 @@@ static void ixgbe_cache_ring_register(s
        adapter->rx_ring[0].reg_idx = 0;
        adapter->tx_ring[0].reg_idx = 0;
  
 +      if (ixgbe_cache_ring_sriov(adapter))
 +              return;
 +
  #ifdef IXGBE_FCOE
        if (ixgbe_cache_ring_fcoe(adapter))
                return;
@@@ -3902,9 -3700,6 +3902,9 @@@ static int ixgbe_set_interrupt_capabili
        adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
        adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
        adapter->atr_sample_rate = 0;
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 +              ixgbe_disable_sriov(adapter);
 +
        ixgbe_set_num_queues(adapter);
  
        err = pci_enable_msi(adapter->pdev);
@@@ -5133,7 -4928,7 +5133,7 @@@ static int ixgbe_tso(struct ixgbe_adapt
                                                                 iph->daddr, 0,
                                                                 IPPROTO_TCP,
                                                                 0);
-               } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
+               } else if (skb_is_gso_v6(skb)) {
                        ipv6_hdr(skb)->payload_len = 0;
                        tcp_hdr(skb)->check =
                            ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
@@@ -5689,8 -5484,7 +5689,8 @@@ static int ixgbe_set_mac(struct net_dev
        memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
        memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);
  
 -      hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 +      hw->mac.ops.set_rar(hw, 0, hw->mac.addr, adapter->num_vfs,
 +                          IXGBE_RAH_AV);
  
        return 0;
  }
@@@ -5827,61 -5621,6 +5827,61 @@@ static const struct net_device_ops ixgb
  #endif /* IXGBE_FCOE */
  };
  
 +static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
 +                         const struct ixgbe_info *ii)
 +{
 +#ifdef CONFIG_PCI_IOV
 +      struct ixgbe_hw *hw = &adapter->hw;
 +      int err;
 +
 +      if (hw->mac.type != ixgbe_mac_82599EB || !max_vfs)
 +              return;
 +
 +      /* The 82599 supports up to 64 VFs per physical function
 +       * but this implementation limits allocation to 63 so that
 +       * basic networking resources are still available to the
 +       * physical function
 +       */
 +      adapter->num_vfs = (max_vfs > 63) ? 63 : max_vfs;
 +      adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
 +      err = pci_enable_sriov(adapter->pdev, adapter->num_vfs);
 +      if (err) {
 +              DPRINTK(PROBE, ERR,
 +                      "Failed to enable PCI sriov: %d\n", err);
 +              goto err_novfs;
 +      }
 +      /* If call to enable VFs succeeded then allocate memory
 +       * for per VF control structures.
 +       */
 +      adapter->vfinfo =
 +              kcalloc(adapter->num_vfs,
 +                      sizeof(struct vf_data_storage), GFP_KERNEL);
 +      if (adapter->vfinfo) {
 +              /* Now that we're sure SR-IOV is enabled
 +               * and memory allocated set up the mailbox parameters
 +               */
 +              ixgbe_init_mbx_params_pf(hw);
 +              memcpy(&hw->mbx.ops, ii->mbx_ops,
 +                     sizeof(hw->mbx.ops));
 +
 +              /* Disable RSC when in SR-IOV mode */
 +              adapter->flags2 &= ~(IXGBE_FLAG2_RSC_CAPABLE |
 +                                   IXGBE_FLAG2_RSC_ENABLED);
 +              return;
 +      }
 +
 +      /* Oh oh */
 +      DPRINTK(PROBE, ERR,
 +              "Unable to allocate memory for VF "
 +              "Data Storage - SRIOV disabled\n");
 +      pci_disable_sriov(adapter->pdev);
 +
 +err_novfs:
 +      adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
 +      adapter->num_vfs = 0;
 +#endif /* CONFIG_PCI_IOV */
 +}
 +
  /**
   * ixgbe_probe - Device Initialization Routine
   * @pdev: PCI device information struct
@@@ -6056,8 -5795,6 +6056,8 @@@ static int __devinit ixgbe_probe(struc
                goto err_sw_init;
        }
  
 +      ixgbe_probe_vf(adapter, ii);
 +
        netdev->features = NETIF_F_SG |
                           NETIF_F_IP_CSUM |
                           NETIF_F_HW_VLAN_TX |
        netdev->vlan_features |= NETIF_F_IPV6_CSUM;
        netdev->vlan_features |= NETIF_F_SG;
  
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 +              adapter->flags &= ~(IXGBE_FLAG_RSS_ENABLED |
 +                                  IXGBE_FLAG_DCB_ENABLED);
        if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
                adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
  
                ixgbe_setup_dca(adapter);
        }
  #endif
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
 +              DPRINTK(PROBE, INFO, "IOV is enabled with %d VFs\n",
 +                      adapter->num_vfs);
 +              for (i = 0; i < adapter->num_vfs; i++)
 +                      ixgbe_vf_configuration(pdev, (i | 0x10000000));
 +      }
 +
        /* add san mac addr to netdev */
        ixgbe_add_sanmac_netdev(netdev);
  
@@@ -6226,8 -5953,6 +6226,8 @@@ err_register
        ixgbe_clear_interrupt_scheme(adapter);
  err_sw_init:
  err_eeprom:
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 +              ixgbe_disable_sriov(adapter);
        clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
        del_timer_sync(&adapter->sfp_timer);
        cancel_work_sync(&adapter->sfp_task);
@@@ -6296,9 -6021,6 +6296,9 @@@ static void __devexit ixgbe_remove(stru
        if (netdev->reg_state == NETREG_REGISTERED)
                unregister_netdev(netdev);
  
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 +              ixgbe_disable_sriov(adapter);
 +
        ixgbe_clear_interrupt_scheme(adapter);
  
        ixgbe_release_hw_control(adapter);
@@@ -73,19 -73,7 +73,19 @@@ static int qlge_irq_type = MSIX_IRQ
  module_param(qlge_irq_type, int, MSIX_IRQ);
  MODULE_PARM_DESC(qlge_irq_type, "0 = MSI-X, 1 = MSI, 2 = Legacy.");
  
 -static struct pci_device_id qlge_pci_tbl[] __devinitdata = {
 +static int qlge_mpi_coredump;
 +module_param(qlge_mpi_coredump, int, 0);
 +MODULE_PARM_DESC(qlge_mpi_coredump,
 +              "Option to enable MPI firmware dump. "
 +              "Default is OFF - Do Not allocate memory. ");
 +
 +static int qlge_force_coredump;
 +module_param(qlge_force_coredump, int, 0);
 +MODULE_PARM_DESC(qlge_force_coredump,
 +              "Option to allow force of firmware core dump. "
 +              "Default is OFF - Do not allow.");
 +
 +static DEFINE_PCI_DEVICE_TABLE(qlge_pci_tbl) = {
        {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID_8012)},
        {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID_8000)},
        /* required last entry */
@@@ -464,7 -452,9 +464,7 @@@ static int ql_set_mac_addr(struct ql_ad
        if (set) {
                addr = &qdev->ndev->dev_addr[0];
                QPRINTK(qdev, IFUP, DEBUG,
 -                      "Set Mac addr %02x:%02x:%02x:%02x:%02x:%02x\n",
 -                      addr[0], addr[1], addr[2], addr[3],
 -                      addr[4], addr[5]);
 +                      "Set Mac addr %pM\n", addr);
        } else {
                memset(zero_mac_addr, 0, ETH_ALEN);
                addr = &zero_mac_addr[0];
@@@ -1443,254 -1433,6 +1443,254 @@@ map_error
        return NETDEV_TX_BUSY;
  }
  
 +/* Process an inbound completion from an rx ring. */
 +static void ql_process_mac_rx_gro_page(struct ql_adapter *qdev,
 +                                      struct rx_ring *rx_ring,
 +                                      struct ib_mac_iocb_rsp *ib_mac_rsp,
 +                                      u32 length,
 +                                      u16 vlan_id)
 +{
 +      struct sk_buff *skb;
 +      struct bq_desc *lbq_desc = ql_get_curr_lchunk(qdev, rx_ring);
 +      struct skb_frag_struct *rx_frag;
 +      int nr_frags;
 +      struct napi_struct *napi = &rx_ring->napi;
 +
 +      napi->dev = qdev->ndev;
 +
 +      skb = napi_get_frags(napi);
 +      if (!skb) {
 +              QPRINTK(qdev, DRV, ERR, "Couldn't get an skb, exiting.\n");
 +              rx_ring->rx_dropped++;
 +              put_page(lbq_desc->p.pg_chunk.page);
 +              return;
 +      }
 +      prefetch(lbq_desc->p.pg_chunk.va);
 +      rx_frag = skb_shinfo(skb)->frags;
 +      nr_frags = skb_shinfo(skb)->nr_frags;
 +      rx_frag += nr_frags;
 +      rx_frag->page = lbq_desc->p.pg_chunk.page;
 +      rx_frag->page_offset = lbq_desc->p.pg_chunk.offset;
 +      rx_frag->size = length;
 +
 +      skb->len += length;
 +      skb->data_len += length;
 +      skb->truesize += length;
 +      skb_shinfo(skb)->nr_frags++;
 +
 +      rx_ring->rx_packets++;
 +      rx_ring->rx_bytes += length;
 +      skb->ip_summed = CHECKSUM_UNNECESSARY;
 +      skb_record_rx_queue(skb, rx_ring->cq_id);
 +      if (qdev->vlgrp && (vlan_id != 0xffff))
 +              vlan_gro_frags(&rx_ring->napi, qdev->vlgrp, vlan_id);
 +      else
 +              napi_gro_frags(napi);
 +}
 +
 +/* Process an inbound completion from an rx ring. */
 +static void ql_process_mac_rx_page(struct ql_adapter *qdev,
 +                                      struct rx_ring *rx_ring,
 +                                      struct ib_mac_iocb_rsp *ib_mac_rsp,
 +                                      u32 length,
 +                                      u16 vlan_id)
 +{
 +      struct net_device *ndev = qdev->ndev;
 +      struct sk_buff *skb = NULL;
 +      void *addr;
 +      struct bq_desc *lbq_desc = ql_get_curr_lchunk(qdev, rx_ring);
 +      struct napi_struct *napi = &rx_ring->napi;
 +
 +      skb = netdev_alloc_skb(ndev, length);
 +      if (!skb) {
 +              QPRINTK(qdev, DRV, ERR, "Couldn't get an skb, "
 +                              "need to unwind!.\n");
 +              rx_ring->rx_dropped++;
 +              put_page(lbq_desc->p.pg_chunk.page);
 +              return;
 +      }
 +
 +      addr = lbq_desc->p.pg_chunk.va;
 +      prefetch(addr);
 +
 +
 +      /* Frame error, so drop the packet. */
 +      if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) {
 +              QPRINTK(qdev, DRV, ERR, "Receive error, flags2 = 0x%x\n",
 +                              ib_mac_rsp->flags2);
 +              rx_ring->rx_errors++;
 +              goto err_out;
 +      }
 +
 +      /* The max framesize filter on this chip is set higher than
 +       * MTU since FCoE uses 2k frames.
 +       */
 +      if (skb->len > ndev->mtu + ETH_HLEN) {
 +              QPRINTK(qdev, DRV, ERR, "Segment too small, dropping.\n");
 +              rx_ring->rx_dropped++;
 +              goto err_out;
 +      }
 +      memcpy(skb_put(skb, ETH_HLEN), addr, ETH_HLEN);
 +      QPRINTK(qdev, RX_STATUS, DEBUG,
 +              "%d bytes of headers and data in large. Chain "
 +              "page to new skb and pull tail.\n", length);
 +      skb_fill_page_desc(skb, 0, lbq_desc->p.pg_chunk.page,
 +                              lbq_desc->p.pg_chunk.offset+ETH_HLEN,
 +                              length-ETH_HLEN);
 +      skb->len += length-ETH_HLEN;
 +      skb->data_len += length-ETH_HLEN;
 +      skb->truesize += length-ETH_HLEN;
 +
 +      rx_ring->rx_packets++;
 +      rx_ring->rx_bytes += skb->len;
 +      skb->protocol = eth_type_trans(skb, ndev);
 +      skb->ip_summed = CHECKSUM_NONE;
 +
 +      if (qdev->rx_csum &&
 +              !(ib_mac_rsp->flags1 & IB_MAC_CSUM_ERR_MASK)) {
 +              /* TCP frame. */
 +              if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_T) {
 +                      QPRINTK(qdev, RX_STATUS, DEBUG,
 +                                      "TCP checksum done!\n");
 +                      skb->ip_summed = CHECKSUM_UNNECESSARY;
 +              } else if ((ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) &&
 +                              (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_V4)) {
 +                      /* Unfragmented ipv4 UDP frame. */
 +                      struct iphdr *iph = (struct iphdr *) skb->data;
 +                      if (!(iph->frag_off &
 +                              cpu_to_be16(IP_MF|IP_OFFSET))) {
 +                              skb->ip_summed = CHECKSUM_UNNECESSARY;
 +                              QPRINTK(qdev, RX_STATUS, DEBUG,
 +                                              "TCP checksum done!\n");
 +                      }
 +              }
 +      }
 +
 +      skb_record_rx_queue(skb, rx_ring->cq_id);
 +      if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
 +              if (qdev->vlgrp && (vlan_id != 0xffff))
 +                      vlan_gro_receive(napi, qdev->vlgrp, vlan_id, skb);
 +              else
 +                      napi_gro_receive(napi, skb);
 +      } else {
 +              if (qdev->vlgrp && (vlan_id != 0xffff))
 +                      vlan_hwaccel_receive_skb(skb, qdev->vlgrp, vlan_id);
 +              else
 +                      netif_receive_skb(skb);
 +      }
 +      return;
 +err_out:
 +      dev_kfree_skb_any(skb);
 +      put_page(lbq_desc->p.pg_chunk.page);
 +}
 +
 +/* Process an inbound completion from an rx ring. */
 +static void ql_process_mac_rx_skb(struct ql_adapter *qdev,
 +                                      struct rx_ring *rx_ring,
 +                                      struct ib_mac_iocb_rsp *ib_mac_rsp,
 +                                      u32 length,
 +                                      u16 vlan_id)
 +{
 +      struct net_device *ndev = qdev->ndev;
 +      struct sk_buff *skb = NULL;
 +      struct sk_buff *new_skb = NULL;
 +      struct bq_desc *sbq_desc = ql_get_curr_sbuf(rx_ring);
 +
 +      skb = sbq_desc->p.skb;
 +      /* Allocate new_skb and copy */
 +      new_skb = netdev_alloc_skb(qdev->ndev, length + NET_IP_ALIGN);
 +      if (new_skb == NULL) {
 +              QPRINTK(qdev, PROBE, ERR,
 +                      "No skb available, drop the packet.\n");
 +              rx_ring->rx_dropped++;
 +              return;
 +      }
 +      skb_reserve(new_skb, NET_IP_ALIGN);
 +      memcpy(skb_put(new_skb, length), skb->data, length);
 +      skb = new_skb;
 +
 +      /* Frame error, so drop the packet. */
 +      if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) {
 +              QPRINTK(qdev, DRV, ERR, "Receive error, flags2 = 0x%x\n",
 +                                      ib_mac_rsp->flags2);
 +              dev_kfree_skb_any(skb);
 +              rx_ring->rx_errors++;
 +              return;
 +      }
 +
 +      /* loopback self test for ethtool */
 +      if (test_bit(QL_SELFTEST, &qdev->flags)) {
 +              ql_check_lb_frame(qdev, skb);
 +              dev_kfree_skb_any(skb);
 +              return;
 +      }
 +
 +      /* The max framesize filter on this chip is set higher than
 +       * MTU since FCoE uses 2k frames.
 +       */
 +      if (skb->len > ndev->mtu + ETH_HLEN) {
 +              dev_kfree_skb_any(skb);
 +              rx_ring->rx_dropped++;
 +              return;
 +      }
 +
 +      prefetch(skb->data);
 +      skb->dev = ndev;
 +      if (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) {
 +              QPRINTK(qdev, RX_STATUS, DEBUG, "%s%s%s Multicast.\n",
 +                      (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) ==
 +                      IB_MAC_IOCB_RSP_M_HASH ? "Hash" : "",
 +                      (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) ==
 +                      IB_MAC_IOCB_RSP_M_REG ? "Registered" : "",
 +                      (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) ==
 +                      IB_MAC_IOCB_RSP_M_PROM ? "Promiscuous" : "");
 +      }
 +      if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_P)
 +              QPRINTK(qdev, RX_STATUS, DEBUG, "Promiscuous Packet.\n");
 +
 +      rx_ring->rx_packets++;
 +      rx_ring->rx_bytes += skb->len;
 +      skb->protocol = eth_type_trans(skb, ndev);
 +      skb->ip_summed = CHECKSUM_NONE;
 +
 +      /* If rx checksum is on, and there are no
 +       * csum or frame errors.
 +       */
 +      if (qdev->rx_csum &&
 +              !(ib_mac_rsp->flags1 & IB_MAC_CSUM_ERR_MASK)) {
 +              /* TCP frame. */
 +              if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_T) {
 +                      QPRINTK(qdev, RX_STATUS, DEBUG,
 +                                      "TCP checksum done!\n");
 +                      skb->ip_summed = CHECKSUM_UNNECESSARY;
 +              } else if ((ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) &&
 +                              (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_V4)) {
 +                      /* Unfragmented ipv4 UDP frame. */
 +                      struct iphdr *iph = (struct iphdr *) skb->data;
 +                      if (!(iph->frag_off &
 +                              cpu_to_be16(IP_MF|IP_OFFSET))) {
 +                              skb->ip_summed = CHECKSUM_UNNECESSARY;
 +                              QPRINTK(qdev, RX_STATUS, DEBUG,
 +                                              "TCP checksum done!\n");
 +                      }
 +              }
 +      }
 +
 +      skb_record_rx_queue(skb, rx_ring->cq_id);
 +      if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
 +              if (qdev->vlgrp && (vlan_id != 0xffff))
 +                      vlan_gro_receive(&rx_ring->napi, qdev->vlgrp,
 +                                              vlan_id, skb);
 +              else
 +                      napi_gro_receive(&rx_ring->napi, skb);
 +      } else {
 +              if (qdev->vlgrp && (vlan_id != 0xffff))
 +                      vlan_hwaccel_receive_skb(skb, qdev->vlgrp, vlan_id);
 +              else
 +                      netif_receive_skb(skb);
 +      }
 +}
 +
  static void ql_realign_skb(struct sk_buff *skb, int len)
  {
        void *temp_addr = skb->data;
@@@ -1904,13 -1646,14 +1904,13 @@@ static struct sk_buff *ql_build_rx_skb(
  }
  
  /* Process an inbound completion from an rx ring. */
 -static void ql_process_mac_rx_intr(struct ql_adapter *qdev,
 +static void ql_process_mac_split_rx_intr(struct ql_adapter *qdev,
                                   struct rx_ring *rx_ring,
 -                                 struct ib_mac_iocb_rsp *ib_mac_rsp)
 +                                 struct ib_mac_iocb_rsp *ib_mac_rsp,
 +                                 u16 vlan_id)
  {
        struct net_device *ndev = qdev->ndev;
        struct sk_buff *skb = NULL;
 -      u16 vlan_id = (le16_to_cpu(ib_mac_rsp->vlan_id) &
 -                      IB_MAC_IOCB_RSP_VLAN_MASK)
  
        QL_DUMP_IB_MAC_RSP(ib_mac_rsp);
  
        }
  }
  
 +/* Process an inbound completion from an rx ring. */
 +static unsigned long ql_process_mac_rx_intr(struct ql_adapter *qdev,
 +                                      struct rx_ring *rx_ring,
 +                                      struct ib_mac_iocb_rsp *ib_mac_rsp)
 +{
 +      u32 length = le32_to_cpu(ib_mac_rsp->data_len);
 +      u16 vlan_id = (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_V) ?
 +                      ((le16_to_cpu(ib_mac_rsp->vlan_id) &
 +                      IB_MAC_IOCB_RSP_VLAN_MASK)) : 0xffff;
 +
 +      QL_DUMP_IB_MAC_RSP(ib_mac_rsp);
 +
 +      if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
 +              /* The data and headers are split into
 +               * separate buffers.
 +               */
 +              ql_process_mac_split_rx_intr(qdev, rx_ring, ib_mac_rsp,
 +                                              vlan_id);
 +      } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DS) {
 +              /* The data fit in a single small buffer.
 +               * Allocate a new skb, copy the data and
 +               * return the buffer to the free pool.
 +               */
 +              ql_process_mac_rx_skb(qdev, rx_ring, ib_mac_rsp,
 +                                              length, vlan_id);
 +      } else if ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL) &&
 +              !(ib_mac_rsp->flags1 & IB_MAC_CSUM_ERR_MASK) &&
 +              (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_T)) {
 +              /* TCP packet in a page chunk that's been checksummed.
 +               * Tack it on to our GRO skb and let it go.
 +               */
 +              ql_process_mac_rx_gro_page(qdev, rx_ring, ib_mac_rsp,
 +                                              length, vlan_id);
 +      } else if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL) {
 +              /* Non-TCP packet in a page chunk. Allocate an
 +               * skb, tack it on frags, and send it up.
 +               */
 +              ql_process_mac_rx_page(qdev, rx_ring, ib_mac_rsp,
 +                                              length, vlan_id);
 +      } else {
 +              struct bq_desc *lbq_desc;
 +
 +              /* Free small buffer that holds the IAL */
 +              lbq_desc = ql_get_curr_sbuf(rx_ring);
 +              QPRINTK(qdev, RX_ERR, ERR, "Dropping frame, len %d > mtu %d\n",
 +                      length, qdev->ndev->mtu);
 +
 +              /* Unwind the large buffers for this frame. */
 +              while (length > 0) {
 +                      lbq_desc = ql_get_curr_lchunk(qdev, rx_ring);
 +                      length -= (length < rx_ring->lbq_buf_size) ?
 +                              length : rx_ring->lbq_buf_size;
 +                      put_page(lbq_desc->p.pg_chunk.page);
 +              }
 +      }
 +
 +      return (unsigned long)length;
 +}
 +
  /* Process an outbound completion from an rx ring. */
  static void ql_process_mac_tx_intr(struct ql_adapter *qdev,
                                   struct ob_mac_iocb_rsp *mac_rsp)
@@@ -3648,15 -3332,15 +3648,15 @@@ static int ql_adapter_initialize(struc
  
        /* Enable the function, set pagesize, enable error checking. */
        value = FSC_FE | FSC_EPC_INBOUND | FSC_EPC_OUTBOUND |
 -          FSC_EC | FSC_VM_PAGE_4K | FSC_SH;
 +          FSC_EC | FSC_VM_PAGE_4K;
 +      value |= SPLT_SETTING;
  
        /* Set/clear header splitting. */
        mask = FSC_VM_PAGESIZE_MASK |
            FSC_DBL_MASK | FSC_DBRST_MASK | (value << 16);
        ql_write32(qdev, FSC, mask | value);
  
 -      ql_write32(qdev, SPLT_HDR, SPLT_HDR_EP |
 -              min(SMALL_BUF_MAP_SIZE, MAX_SPLIT_SIZE));
 +      ql_write32(qdev, SPLT_HDR, SPLT_LEN);
  
        /* Set RX packet routing to use port/pci function on which the
         * packet arrived on in addition to usual frame routing.
@@@ -3854,7 -3538,6 +3854,7 @@@ static int ql_adapter_down(struct ql_ad
        cancel_delayed_work_sync(&qdev->mpi_reset_work);
        cancel_delayed_work_sync(&qdev->mpi_work);
        cancel_delayed_work_sync(&qdev->mpi_idc_work);
 +      cancel_delayed_work_sync(&qdev->mpi_core_to_log);
        cancel_delayed_work_sync(&qdev->mpi_port_cfg_work);
  
        for (i = 0; i < qdev->rss_ring_count; i++)
@@@ -4411,7 -4094,6 +4411,7 @@@ static void ql_release_all(struct pci_d
                iounmap(qdev->reg_base);
        if (qdev->doorbell_area)
                iounmap(qdev->doorbell_area);
 +      vfree(qdev->mpi_coredump);
        pci_release_regions(pdev);
        pci_set_drvdata(pdev, NULL);
  }
@@@ -4437,7 -4119,7 +4437,7 @@@ static int __devinit ql_init_device(str
        err = pcie_set_readrq(pdev, 4096);
        if (err) {
                dev_err(&pdev->dev, "Set readrq failed.\n");
-               goto err_out;
+               goto err_out1;
        }
  
        err = pci_request_regions(pdev, DRV_NAME);
  
        if (err) {
                dev_err(&pdev->dev, "No usable DMA configuration.\n");
-               goto err_out;
+               goto err_out2;
        }
  
        /* Set PCIe reset type for EEH to fundamental. */
        if (!qdev->reg_base) {
                dev_err(&pdev->dev, "Register mapping failed.\n");
                err = -ENOMEM;
-               goto err_out;
+               goto err_out2;
        }
  
        qdev->doorbell_area_size = pci_resource_len(pdev, 3);
        if (!qdev->doorbell_area) {
                dev_err(&pdev->dev, "Doorbell register mapping failed.\n");
                err = -ENOMEM;
-               goto err_out;
+               goto err_out2;
        }
  
        err = ql_get_board_info(qdev);
        if (err) {
                dev_err(&pdev->dev, "Register access failed.\n");
                err = -EIO;
-               goto err_out;
+               goto err_out2;
        }
        qdev->msg_enable = netif_msg_init(debug, default_msg);
        spin_lock_init(&qdev->hw_lock);
        spin_lock_init(&qdev->stats_lock);
  
 +      if (qlge_mpi_coredump) {
 +              qdev->mpi_coredump =
 +                      vmalloc(sizeof(struct ql_mpi_coredump));
 +              if (qdev->mpi_coredump == NULL) {
 +                      dev_err(&pdev->dev, "Coredump alloc failed.\n");
 +                      err = -ENOMEM;
 +                      goto err_out;
 +              }
 +              if (qlge_force_coredump)
 +                      set_bit(QL_FRC_COREDUMP, &qdev->flags);
 +      }
        /* make sure the EEPROM is good */
        err = qdev->nic_ops->get_flash(qdev);
        if (err) {
                dev_err(&pdev->dev, "Invalid FLASH.\n");
-               goto err_out;
+               goto err_out2;
        }
  
        memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
        INIT_DELAYED_WORK(&qdev->mpi_work, ql_mpi_work);
        INIT_DELAYED_WORK(&qdev->mpi_port_cfg_work, ql_mpi_port_cfg_work);
        INIT_DELAYED_WORK(&qdev->mpi_idc_work, ql_mpi_idc_work);
 +      INIT_DELAYED_WORK(&qdev->mpi_core_to_log, ql_mpi_core_to_log);
        init_completion(&qdev->ide_completion);
  
        if (!cards_found) {
                         DRV_NAME, DRV_VERSION);
        }
        return 0;
- err_out:
+ err_out2:
        ql_release_all(pdev);
+ err_out1:
        pci_disable_device(pdev);
        return err;
  }
@@@ -4656,7 -4327,6 +4657,7 @@@ static void ql_eeh_close(struct net_dev
        cancel_delayed_work_sync(&qdev->mpi_reset_work);
        cancel_delayed_work_sync(&qdev->mpi_work);
        cancel_delayed_work_sync(&qdev->mpi_idc_work);
 +      cancel_delayed_work_sync(&qdev->mpi_core_to_log);
        cancel_delayed_work_sync(&qdev->mpi_port_cfg_work);
  
        for (i = 0; i < qdev->rss_ring_count; i++)
diff --combined drivers/net/sky2.c
@@@ -644,6 -644,7 +644,7 @@@ static void sky2_phy_power_up(struct sk
  {
        u32 reg1;
  
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
        reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
        reg1 &= ~phy_power[port];
  
                reg1 |= coma_mode[port];
  
        sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        sky2_pci_read32(hw, PCI_DEV_REG1);
  
        if (hw->chip_id == CHIP_ID_YUKON_FE)
@@@ -707,9 -709,11 +709,11 @@@ static void sky2_phy_power_down(struct 
                gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_PDOWN);
        }
  
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
        reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
        reg1 |= phy_power[port];                /* set PHY to PowerDown/COMA Mode */
        sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
  }
  
  /* Force a renegotiation */
@@@ -2149,7 -2153,9 +2153,9 @@@ static void sky2_qlink_intr(struct sky2
  
        /* reset PHY Link Detect */
        phy = sky2_pci_read16(hw, PSM_CONFIG_REG4);
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
        sky2_pci_write16(hw, PSM_CONFIG_REG4, phy | 1);
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
  
        sky2_link_up(sky2);
  }
@@@ -2640,6 -2646,7 +2646,7 @@@ static void sky2_hw_intr(struct sky2_h
        if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
                u16 pci_err;
  
+               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
                pci_err = sky2_pci_read16(hw, PCI_STATUS);
                if (net_ratelimit())
                        dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
  
                sky2_pci_write16(hw, PCI_STATUS,
                                      pci_err | PCI_STATUS_ERROR_BITS);
+               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        }
  
        if (status & Y2_IS_PCI_EXP) {
                /* PCI-Express uncorrectable Error occurred */
                u32 err;
  
+               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
                err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
                sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
                             0xfffffffful);
                        dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
  
                sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
+               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        }
  
        if (status & Y2_HWE_L1_MASK)
@@@ -3038,6 -3048,7 +3048,7 @@@ static void sky2_reset(struct sky2_hw *
        }
  
        sky2_power_on(hw);
+       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
  
        for (i = 0; i < hw->ports; i++) {
                sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
                reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE;
  
                /* reset PHY Link Detect */
+               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
                sky2_pci_write16(hw, PSM_CONFIG_REG4,
                                 reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT);
                sky2_pci_write16(hw, PSM_CONFIG_REG4, reg);
                        /* restore the PCIe Link Control register */
                        sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg);
                }
+               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
  
                /* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */
                sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16));
  static void sky2_detach(struct net_device *dev)
  {
        if (netif_running(dev)) {
 +              netif_tx_lock(dev);
                netif_device_detach(dev);       /* stop txq */
 +              netif_tx_unlock(dev);
                sky2_down(dev);
        }
  }
@@@ -3230,6 -3241,27 +3243,27 @@@ static inline u8 sky2_wol_supported(con
        return sky2_is_copper(hw) ? (WAKE_PHY | WAKE_MAGIC) : 0;
  }
  
+ static void sky2_hw_set_wol(struct sky2_hw *hw)
+ {
+       int wol = 0;
+       int i;
+       for (i = 0; i < hw->ports; i++) {
+               struct net_device *dev = hw->dev[i];
+               struct sky2_port *sky2 = netdev_priv(dev);
+               if (sky2->wol)
+                       wol = 1;
+       }
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U ||
+           hw->chip_id == CHIP_ID_YUKON_EX ||
+           hw->chip_id == CHIP_ID_YUKON_FE_P)
+               sky2_write32(hw, B0_CTST, wol ? Y2_HW_WOL_ON : Y2_HW_WOL_OFF);
+       device_set_wakeup_enable(&hw->pdev->dev, wol);
+ }
  static void sky2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
  {
        const struct sky2_port *sky2 = netdev_priv(dev);
@@@ -3249,13 -3281,7 +3283,7 @@@ static int sky2_set_wol(struct net_devi
  
        sky2->wol = wol->wolopts;
  
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U ||
-           hw->chip_id == CHIP_ID_YUKON_EX ||
-           hw->chip_id == CHIP_ID_YUKON_FE_P)
-               sky2_write32(hw, B0_CTST, sky2->wol
-                            ? Y2_HW_WOL_ON : Y2_HW_WOL_OFF);
-       device_set_wakeup_enable(&hw->pdev->dev, sky2->wol);
+       sky2_hw_set_wol(hw);
  
        if (!netif_running(dev))
                sky2_wol_init(sky2);
@@@ -3840,50 -3866,6 +3868,50 @@@ static int sky2_get_regs_len(struct net
        return 0x4000;
  }
  
 +static int sky2_reg_access_ok(struct sky2_hw *hw, unsigned int b)
 +{
 +      /* This complicated switch statement is to make sure and
 +       * only access regions that are unreserved.
 +       * Some blocks are only valid on dual port cards.
 +       */
 +      switch (b) {
 +      /* second port */
 +      case 5:         /* Tx Arbiter 2 */
 +      case 9:         /* RX2 */
 +      case 14 ... 15: /* TX2 */
 +      case 17: case 19: /* Ram Buffer 2 */
 +      case 22 ... 23: /* Tx Ram Buffer 2 */
 +      case 25:        /* Rx MAC Fifo 1 */
 +      case 27:        /* Tx MAC Fifo 2 */
 +      case 31:        /* GPHY 2 */
 +      case 40 ... 47: /* Pattern Ram 2 */
 +      case 52: case 54: /* TCP Segmentation 2 */
 +      case 112 ... 116: /* GMAC 2 */
 +              return hw->ports > 1;
 +
 +      case 0:         /* Control */
 +      case 2:         /* Mac address */
 +      case 4:         /* Tx Arbiter 1 */
 +      case 7:         /* PCI express reg */
 +      case 8:         /* RX1 */
 +      case 12 ... 13: /* TX1 */
 +      case 16: case 18:/* Rx Ram Buffer 1 */
 +      case 20 ... 21: /* Tx Ram Buffer 1 */
 +      case 24:        /* Rx MAC Fifo 1 */
 +      case 26:        /* Tx MAC Fifo 1 */
 +      case 28 ... 29: /* Descriptor and status unit */
 +      case 30:        /* GPHY 1*/
 +      case 32 ... 39: /* Pattern Ram 1 */
 +      case 48: case 50: /* TCP Segmentation 1 */
 +      case 56 ... 60: /* PCI space */
 +      case 80 ... 84: /* GMAC 1 */
 +              return 1;
 +
 +      default:
 +              return 0;
 +      }
 +}
 +
  /*
   * Returns copy of control register region
   * Note: ethtool_get_regs always provides full size (16k) buffer
@@@ -3898,13 -3880,55 +3926,13 @@@ static void sky2_get_regs(struct net_de
        regs->version = 1;
  
        for (b = 0; b < 128; b++) {
 -              /* This complicated switch statement is to make sure and
 -               * only access regions that are unreserved.
 -               * Some blocks are only valid on dual port cards.
 -               * and block 3 has some special diagnostic registers that
 -               * are poison.
 -               */
 -              switch (b) {
 -              case 3:
 -                      /* skip diagnostic ram region */
 +              /* skip poisonous diagnostic ram region in block 3 */
 +              if (b == 3)
                        memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10);
 -                      break;
 -
 -              /* dual port cards only */
 -              case 5:         /* Tx Arbiter 2 */
 -              case 9:         /* RX2 */
 -              case 14 ... 15: /* TX2 */
 -              case 17: case 19: /* Ram Buffer 2 */
 -              case 22 ... 23: /* Tx Ram Buffer 2 */
 -              case 25:        /* Rx MAC Fifo 1 */
 -              case 27:        /* Tx MAC Fifo 2 */
 -              case 31:        /* GPHY 2 */
 -              case 40 ... 47: /* Pattern Ram 2 */
 -              case 52: case 54: /* TCP Segmentation 2 */
 -              case 112 ... 116: /* GMAC 2 */
 -                      if (sky2->hw->ports == 1)
 -                              goto reserved;
 -                      /* fall through */
 -              case 0:         /* Control */
 -              case 2:         /* Mac address */
 -              case 4:         /* Tx Arbiter 1 */
 -              case 7:         /* PCI express reg */
 -              case 8:         /* RX1 */
 -              case 12 ... 13: /* TX1 */
 -              case 16: case 18:/* Rx Ram Buffer 1 */
 -              case 20 ... 21: /* Tx Ram Buffer 1 */
 -              case 24:        /* Rx MAC Fifo 1 */
 -              case 26:        /* Tx MAC Fifo 1 */
 -              case 28 ... 29: /* Descriptor and status unit */
 -              case 30:        /* GPHY 1*/
 -              case 32 ... 39: /* Pattern Ram 1 */
 -              case 48: case 50: /* TCP Segmentation 1 */
 -              case 56 ... 60: /* PCI space */
 -              case 80 ... 84: /* GMAC 1 */
 +              else if (sky2_reg_access_ok(sky2->hw, b))
                        memcpy_fromio(p, io, 128);
 -                      break;
 -              default:
 -reserved:
 +              else
                        memset(p, 0, 128);
 -              }
  
                p += 128;
                io += 128;
diff --combined drivers/net/starfire.c
@@@ -301,7 -301,7 +301,7 @@@ enum chipset 
        CH_6915 = 0,
  };
  
 -static struct pci_device_id starfire_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(starfire_pci_tbl) = {
        { 0x9004, 0x6915, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_6915 },
        { 0, }
  };
@@@ -1063,7 -1063,7 +1063,7 @@@ static int netdev_open(struct net_devic
        if (retval) {
                printk(KERN_ERR "starfire: Failed to load firmware \"%s\"\n",
                       FIRMWARE_RX);
-               return retval;
+               goto out_init;
        }
        if (fw_rx->size % 4) {
                printk(KERN_ERR "starfire: bogus length %zu in \"%s\"\n",
@@@ -1108,6 -1108,9 +1108,9 @@@ out_tx
        release_firmware(fw_tx);
  out_rx:
        release_firmware(fw_rx);
+ out_init:
+       if (retval)
+               netdev_close(dev);
        return retval;
  }
  
@@@ -211,7 -211,7 +211,7 @@@ struct tulip_chip_table tulip_tbl[] = 
  };
  
  
 -static struct pci_device_id tulip_pci_tbl[] = {
 +static DEFINE_PCI_DEVICE_TABLE(tulip_pci_tbl) = {
        { 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
        { 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 },
        { 0x11AD, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, LC82C168 },
        { 0x17B3, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
        { 0x10b7, 0x9300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* 3Com 3CSOHO100B-TX */
        { 0x14ea, 0xab08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* Planex FNW-3602-TX */
+       { 0x1414, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* Microsoft MN-120 */
        { 0x1414, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
        { } /* terminate list */
  };
diff --combined drivers/net/virtio_net.c
@@@ -395,8 -395,7 +395,7 @@@ static void refill_work(struct work_str
  
        vi = container_of(work, struct virtnet_info, refill.work);
        napi_disable(&vi->napi);
-       try_fill_recv(vi, GFP_KERNEL);
-       still_empty = (vi->num == 0);
+       still_empty = !try_fill_recv(vi, GFP_KERNEL);
        napi_enable(&vi->napi);
  
        /* In theory, this can happen: if we don't get any buffers in
@@@ -675,7 -674,6 +674,7 @@@ static void virtnet_set_rx_mode(struct 
        struct virtio_net_ctrl_mac *mac_data;
        struct dev_addr_list *addr;
        struct netdev_hw_addr *ha;
 +      int uc_count;
        void *buf;
        int i;
  
                dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n",
                         allmulti ? "en" : "dis");
  
 +      uc_count = netdev_uc_count(dev);
        /* MAC filter - use one buffer for both lists */
 -      mac_data = buf = kzalloc(((dev->uc.count + dev->mc_count) * ETH_ALEN) +
 +      mac_data = buf = kzalloc(((uc_count + dev->mc_count) * ETH_ALEN) +
                                 (2 * sizeof(mac_data->entries)), GFP_ATOMIC);
        if (!buf) {
                dev_warn(&dev->dev, "No memory for MAC address buffer\n");
        sg_init_table(sg, 2);
  
        /* Store the unicast list and count in the front of the buffer */
 -      mac_data->entries = dev->uc.count;
 +      mac_data->entries = uc_count;
        i = 0;
 -      list_for_each_entry(ha, &dev->uc.list, list)
 +      netdev_for_each_uc_addr(ha, dev)
                memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN);
  
        sg_set_buf(&sg[0], mac_data,
 -                 sizeof(mac_data->entries) + (dev->uc.count * ETH_ALEN));
 +                 sizeof(mac_data->entries) + (uc_count * ETH_ALEN));
  
        /* multicast list and count fill the end */
 -      mac_data = (void *)&mac_data->macs[dev->uc.count][0];
 +      mac_data = (void *)&mac_data->macs[uc_count][0];
  
        mac_data->entries = dev->mc_count;
        addr = dev->mc_list;
@@@ -52,6 -52,28 +52,6 @@@ module_exit(ath9k_exit)
  /* Helper Functions */
  /********************/
  
 -static u32 ath9k_hw_mac_usec(struct ath_hw *ah, u32 clks)
 -{
 -      struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
 -
 -      if (!ah->curchan) /* should really check for CCK instead */
 -              return clks / ATH9K_CLOCK_RATE_CCK;
 -      if (conf->channel->band == IEEE80211_BAND_2GHZ)
 -              return clks / ATH9K_CLOCK_RATE_2GHZ_OFDM;
 -
 -      return clks / ATH9K_CLOCK_RATE_5GHZ_OFDM;
 -}
 -
 -static u32 ath9k_hw_mac_to_usec(struct ath_hw *ah, u32 clks)
 -{
 -      struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
 -
 -      if (conf_is_ht40(conf))
 -              return ath9k_hw_mac_usec(ah, clks) / 2;
 -      else
 -              return ath9k_hw_mac_usec(ah, clks);
 -}
 -
  static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs)
  {
        struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
@@@ -321,6 -343,30 +321,6 @@@ static bool ath9k_hw_chip_test(struct a
        return true;
  }
  
 -static const char *ath9k_hw_devname(u16 devid)
 -{
 -      switch (devid) {
 -      case AR5416_DEVID_PCI:
 -              return "Atheros 5416";
 -      case AR5416_DEVID_PCIE:
 -              return "Atheros 5418";
 -      case AR9160_DEVID_PCI:
 -              return "Atheros 9160";
 -      case AR5416_AR9100_DEVID:
 -              return "Atheros 9100";
 -      case AR9280_DEVID_PCI:
 -      case AR9280_DEVID_PCIE:
 -              return "Atheros 9280";
 -      case AR9285_DEVID_PCIE:
 -              return "Atheros 9285";
 -      case AR5416_DEVID_AR9287_PCI:
 -      case AR5416_DEVID_AR9287_PCIE:
 -              return "Atheros 9287";
 -      }
 -
 -      return NULL;
 -}
 -
  static void ath9k_hw_init_config(struct ath_hw *ah)
  {
        int i;
                ah->config.spurchans[i][1] = AR_NO_SPUR;
        }
  
 -      ah->config.intr_mitigation = true;
 +      ah->config.rx_intr_mitigation = true;
  
        /*
         * We need this for PCI devices only (Cardbus, PCI, miniPCI)
@@@ -391,6 -437,8 +391,6 @@@ static void ath9k_hw_init_defaults(stru
        ah->beacon_interval = 100;
        ah->enable_32kHz_clock = DONT_USE_32KHZ;
        ah->slottime = (u32) -1;
 -      ah->acktimeout = (u32) -1;
 -      ah->ctstimeout = (u32) -1;
        ah->globaltxtimeout = (u32) -1;
        ah->power_mode = ATH9K_PM_UNDEFINED;
  }
@@@ -807,12 -855,11 +807,11 @@@ static void ath9k_hw_init_mode_gain_reg
        }
  }
  
- static void ath9k_hw_init_11a_eeprom_fix(struct ath_hw *ah)
+ static void ath9k_hw_init_eeprom_fix(struct ath_hw *ah)
  {
        u32 i, j;
  
-       if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
-           test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) {
+       if (ah->hw_version.devid == AR9280_DEVID_PCI) {
  
                /* EEPROM Fixup */
                for (i = 0; i < ah->iniModes.ia_rows; i++) {
@@@ -932,7 -979,7 +931,7 @@@ int ath9k_hw_init(struct ath_hw *ah
        if (r)
                return r;
  
-       ath9k_hw_init_11a_eeprom_fix(ah);
+       ath9k_hw_init_eeprom_fix(ah);
  
        r = ath9k_hw_init_macaddr(ah);
        if (r) {
@@@ -1136,7 -1183,7 +1135,7 @@@ static void ath9k_hw_init_interrupt_mas
                AR_IMR_RXORN |
                AR_IMR_BCNMISC;
  
 -      if (ah->config.intr_mitigation)
 +      if (ah->config.rx_intr_mitigation)
                ah->mask_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR;
        else
                ah->mask_reg |= AR_IMR_RXOK;
        }
  }
  
 -static bool ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us)
 +static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
  {
 -      if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) {
 -              ath_print(ath9k_hw_common(ah), ATH_DBG_RESET,
 -                        "bad ack timeout %u\n", us);
 -              ah->acktimeout = (u32) -1;
 -              return false;
 -      } else {
 -              REG_RMW_FIELD(ah, AR_TIME_OUT,
 -                            AR_TIME_OUT_ACK, ath9k_hw_mac_to_clks(ah, us));
 -              ah->acktimeout = us;
 -              return true;
 -      }
 +      u32 val = ath9k_hw_mac_to_clks(ah, us);
 +      val = min(val, (u32) 0xFFFF);
 +      REG_WRITE(ah, AR_D_GBL_IFS_SLOT, val);
  }
  
 -static bool ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us)
 +static void ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us)
  {
 -      if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) {
 -              ath_print(ath9k_hw_common(ah), ATH_DBG_RESET,
 -                        "bad cts timeout %u\n", us);
 -              ah->ctstimeout = (u32) -1;
 -              return false;
 -      } else {
 -              REG_RMW_FIELD(ah, AR_TIME_OUT,
 -                            AR_TIME_OUT_CTS, ath9k_hw_mac_to_clks(ah, us));
 -              ah->ctstimeout = us;
 -              return true;
 -      }
 +      u32 val = ath9k_hw_mac_to_clks(ah, us);
 +      val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_ACK));
 +      REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_ACK, val);
 +}
 +
 +static void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us)
 +{
 +      u32 val = ath9k_hw_mac_to_clks(ah, us);
 +      val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_CTS));
 +      REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_CTS, val);
  }
  
  static bool ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu)
        }
  }
  
 -static void ath9k_hw_init_user_settings(struct ath_hw *ah)
 +void ath9k_hw_init_global_settings(struct ath_hw *ah)
  {
 +      struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
 +      int acktimeout;
 +      int slottime;
 +      int sifstime;
 +
        ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
                  ah->misc_mode);
  
        if (ah->misc_mode != 0)
                REG_WRITE(ah, AR_PCU_MISC,
                          REG_READ(ah, AR_PCU_MISC) | ah->misc_mode);
 -      if (ah->slottime != (u32) -1)
 -              ath9k_hw_setslottime(ah, ah->slottime);
 -      if (ah->acktimeout != (u32) -1)
 -              ath9k_hw_set_ack_timeout(ah, ah->acktimeout);
 -      if (ah->ctstimeout != (u32) -1)
 -              ath9k_hw_set_cts_timeout(ah, ah->ctstimeout);
 +
 +      if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
 +              sifstime = 16;
 +      else
 +              sifstime = 10;
 +
 +      /* As defined by IEEE 802.11-2007 17.3.8.6 */
 +      slottime = ah->slottime + 3 * ah->coverage_class;
 +      acktimeout = slottime + sifstime;
 +      ath9k_hw_setslottime(ah, slottime);
 +      ath9k_hw_set_ack_timeout(ah, acktimeout);
 +      ath9k_hw_set_cts_timeout(ah, acktimeout);
        if (ah->globaltxtimeout != (u32) -1)
                ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
  }
 +EXPORT_SYMBOL(ath9k_hw_init_global_settings);
  
 -const char *ath9k_hw_probe(u16 vendorid, u16 devid)
 -{
 -      return vendorid == ATHEROS_VENDOR_ID ?
 -              ath9k_hw_devname(devid) : NULL;
 -}
 -
 -void ath9k_hw_detach(struct ath_hw *ah)
 +void ath9k_hw_deinit(struct ath_hw *ah)
  {
        struct ath_common *common = ath9k_hw_common(ah);
  
@@@ -1239,7 -1289,7 +1238,7 @@@ free_hw
        kfree(ah);
        ah = NULL;
  }
 -EXPORT_SYMBOL(ath9k_hw_detach);
 +EXPORT_SYMBOL(ath9k_hw_deinit);
  
  /*******/
  /* INI */
@@@ -2040,7 -2090,7 +2039,7 @@@ int ath9k_hw_reset(struct ath_hw *ah, s
        if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
                ath9k_enable_rfkill(ah);
  
 -      ath9k_hw_init_user_settings(ah);
 +      ath9k_hw_init_global_settings(ah);
  
        if (AR_SREV_9287_12_OR_LATER(ah)) {
                REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
  
        REG_WRITE(ah, AR_OBS, 8);
  
 -      if (ah->config.intr_mitigation) {
 +      if (ah->config.rx_intr_mitigation) {
                REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
                REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
        }
@@@ -2730,7 -2780,7 +2729,7 @@@ bool ath9k_hw_getisr(struct ath_hw *ah
  
                *masked = isr & ATH9K_INT_COMMON;
  
 -              if (ah->config.intr_mitigation) {
 +              if (ah->config.rx_intr_mitigation) {
                        if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM))
                                *masked |= ATH9K_INT_RX;
                }
@@@ -2863,7 -2913,7 +2862,7 @@@ enum ath9k_int ath9k_hw_set_interrupts(
        }
        if (ints & ATH9K_INT_RX) {
                mask |= AR_IMR_RXERR;
 -              if (ah->config.intr_mitigation)
 +              if (ah->config.rx_intr_mitigation)
                        mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
                else
                        mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
@@@ -3637,6 -3687,21 +3636,6 @@@ u64 ath9k_hw_extend_tsf(struct ath_hw *
  }
  EXPORT_SYMBOL(ath9k_hw_extend_tsf);
  
 -bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
 -{
 -      if (us < ATH9K_SLOT_TIME_9 || us > ath9k_hw_mac_to_usec(ah, 0xffff)) {
 -              ath_print(ath9k_hw_common(ah), ATH_DBG_RESET,
 -                        "bad slot time %u\n", us);
 -              ah->slottime = (u32) -1;
 -              return false;
 -      } else {
 -              REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath9k_hw_mac_to_clks(ah, us));
 -              ah->slottime = us;
 -              return true;
 -      }
 -}
 -EXPORT_SYMBOL(ath9k_hw_setslottime);
 -
  void ath9k_hw_set11nmac2040(struct ath_hw *ah)
  {
        struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
  #include "ath9k.h"
  #include "btcoex.h"
  
 -static char *dev_info = "ath9k";
 -
 -MODULE_AUTHOR("Atheros Communications");
 -MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards.");
 -MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards");
 -MODULE_LICENSE("Dual BSD/GPL");
 -
 -static int modparam_nohwcrypt;
 -module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
 -MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
 -
 -static unsigned int ath9k_debug = ATH_DBG_DEFAULT;
 -module_param_named(debug, ath9k_debug, uint, 0);
 -MODULE_PARM_DESC(debug, "Debugging mask");
 -
 -/* We use the hw_value as an index into our private channel structure */
 -
 -#define CHAN2G(_freq, _idx)  { \
 -      .center_freq = (_freq), \
 -      .hw_value = (_idx), \
 -      .max_power = 20, \
 -}
 -
 -#define CHAN5G(_freq, _idx) { \
 -      .band = IEEE80211_BAND_5GHZ, \
 -      .center_freq = (_freq), \
 -      .hw_value = (_idx), \
 -      .max_power = 20, \
 -}
 -
 -/* Some 2 GHz radios are actually tunable on 2312-2732
 - * on 5 MHz steps, we support the channels which we know
 - * we have calibration data for all cards though to make
 - * this static */
 -static struct ieee80211_channel ath9k_2ghz_chantable[] = {
 -      CHAN2G(2412, 0), /* Channel 1 */
 -      CHAN2G(2417, 1), /* Channel 2 */
 -      CHAN2G(2422, 2), /* Channel 3 */
 -      CHAN2G(2427, 3), /* Channel 4 */
 -      CHAN2G(2432, 4), /* Channel 5 */
 -      CHAN2G(2437, 5), /* Channel 6 */
 -      CHAN2G(2442, 6), /* Channel 7 */
 -      CHAN2G(2447, 7), /* Channel 8 */
 -      CHAN2G(2452, 8), /* Channel 9 */
 -      CHAN2G(2457, 9), /* Channel 10 */
 -      CHAN2G(2462, 10), /* Channel 11 */
 -      CHAN2G(2467, 11), /* Channel 12 */
 -      CHAN2G(2472, 12), /* Channel 13 */
 -      CHAN2G(2484, 13), /* Channel 14 */
 -};
 -
 -/* Some 5 GHz radios are actually tunable on XXXX-YYYY
 - * on 5 MHz steps, we support the channels which we know
 - * we have calibration data for all cards though to make
 - * this static */
 -static struct ieee80211_channel ath9k_5ghz_chantable[] = {
 -      /* _We_ call this UNII 1 */
 -      CHAN5G(5180, 14), /* Channel 36 */
 -      CHAN5G(5200, 15), /* Channel 40 */
 -      CHAN5G(5220, 16), /* Channel 44 */
 -      CHAN5G(5240, 17), /* Channel 48 */
 -      /* _We_ call this UNII 2 */
 -      CHAN5G(5260, 18), /* Channel 52 */
 -      CHAN5G(5280, 19), /* Channel 56 */
 -      CHAN5G(5300, 20), /* Channel 60 */
 -      CHAN5G(5320, 21), /* Channel 64 */
 -      /* _We_ call this "Middle band" */
 -      CHAN5G(5500, 22), /* Channel 100 */
 -      CHAN5G(5520, 23), /* Channel 104 */
 -      CHAN5G(5540, 24), /* Channel 108 */
 -      CHAN5G(5560, 25), /* Channel 112 */
 -      CHAN5G(5580, 26), /* Channel 116 */
 -      CHAN5G(5600, 27), /* Channel 120 */
 -      CHAN5G(5620, 28), /* Channel 124 */
 -      CHAN5G(5640, 29), /* Channel 128 */
 -      CHAN5G(5660, 30), /* Channel 132 */
 -      CHAN5G(5680, 31), /* Channel 136 */
 -      CHAN5G(5700, 32), /* Channel 140 */
 -      /* _We_ call this UNII 3 */
 -      CHAN5G(5745, 33), /* Channel 149 */
 -      CHAN5G(5765, 34), /* Channel 153 */
 -      CHAN5G(5785, 35), /* Channel 157 */
 -      CHAN5G(5805, 36), /* Channel 161 */
 -      CHAN5G(5825, 37), /* Channel 165 */
 -};
 -
 -/* Atheros hardware rate code addition for short premble */
 -#define SHPCHECK(__hw_rate, __flags) \
 -      ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0)
 -
 -#define RATE(_bitrate, _hw_rate, _flags) {              \
 -      .bitrate        = (_bitrate),                   \
 -      .flags          = (_flags),                     \
 -      .hw_value       = (_hw_rate),                   \
 -      .hw_value_short = (SHPCHECK(_hw_rate, _flags))  \
 -}
 -
 -static struct ieee80211_rate ath9k_legacy_rates[] = {
 -      RATE(10, 0x1b, 0),
 -      RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE),
 -      RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE),
 -      RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE),
 -      RATE(60, 0x0b, 0),
 -      RATE(90, 0x0f, 0),
 -      RATE(120, 0x0a, 0),
 -      RATE(180, 0x0e, 0),
 -      RATE(240, 0x09, 0),
 -      RATE(360, 0x0d, 0),
 -      RATE(480, 0x08, 0),
 -      RATE(540, 0x0c, 0),
 -};
 -
  static void ath_cache_conf_rate(struct ath_softc *sc,
                                struct ieee80211_conf *conf)
  {
@@@ -109,7 -221,7 +109,7 @@@ static struct ath9k_channel *ath_get_cu
        return channel;
  }
  
 -static bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
 +bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
  {
        unsigned long flags;
        bool ret;
@@@ -144,10 -256,10 +144,10 @@@ void ath9k_ps_restore(struct ath_softc 
                goto unlock;
  
        if (sc->ps_enabled &&
 -          !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
 -                            SC_OP_WAIT_FOR_CAB |
 -                            SC_OP_WAIT_FOR_PSPOLL_DATA |
 -                            SC_OP_WAIT_FOR_TX_ACK)))
 +          !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
 +                            PS_WAIT_FOR_CAB |
 +                            PS_WAIT_FOR_PSPOLL_DATA |
 +                            PS_WAIT_FOR_TX_ACK)))
                ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
  
   unlock:
@@@ -237,7 -349,7 +237,7 @@@ int ath_set_channel(struct ath_softc *s
   *  When the task is complete, it reschedules itself depending on the
   *  appropriate interval that was calculated.
   */
 -static void ath_ani_calibrate(unsigned long data)
 +void ath_ani_calibrate(unsigned long data)
  {
        struct ath_softc *sc = (struct ath_softc *)data;
        struct ath_hw *ah = sc->sc_ah;
        short_cal_interval = (ah->opmode == NL80211_IFTYPE_AP) ?
                ATH_AP_SHORT_CALINTERVAL : ATH_STA_SHORT_CALINTERVAL;
  
 -      /*
 -      * don't calibrate when we're scanning.
 -      * we are most likely not on our home channel.
 -      */
 -      spin_lock(&sc->ani_lock);
 -      if (sc->sc_flags & SC_OP_SCANNING)
 -              goto set_timer;
 -
        /* Only calibrate if awake */
        if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE)
                goto set_timer;
        ath9k_ps_restore(sc);
  
  set_timer:
 -      spin_unlock(&sc->ani_lock);
        /*
        * Set timer interval based on previous results.
        * The interval must be the shortest necessary to satisfy ANI,
@@@ -392,7 -513,7 +392,7 @@@ static void ath_node_detach(struct ath_
                ath_tx_node_cleanup(sc, an);
  }
  
 -static void ath9k_tasklet(unsigned long data)
 +void ath9k_tasklet(unsigned long data)
  {
        struct ath_softc *sc = (struct ath_softc *)data;
        struct ath_hw *ah = sc->sc_ah;
                 */
                ath_print(common, ATH_DBG_PS,
                          "TSFOOR - Sync with next Beacon\n");
 -              sc->sc_flags |= SC_OP_WAIT_FOR_BEACON | SC_OP_BEACON_SYNC;
 +              sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
        }
  
        if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
@@@ -525,7 -646,7 +525,7 @@@ irqreturn_t ath_isr(int irq, void *dev
                         * receive frames */
                        ath9k_setpower(sc, ATH9K_PM_AWAKE);
                        ath9k_hw_setrxabort(sc->sc_ah, 0);
 -                      sc->sc_flags |= SC_OP_WAIT_FOR_BEACON;
 +                      sc->ps_flags |= PS_WAIT_FOR_BEACON;
                }
  
  chip_reset:
@@@ -812,6 -933,44 +812,6 @@@ static void ath_key_delete(struct ath_c
        }
  }
  
 -static void setup_ht_cap(struct ath_softc *sc,
 -                       struct ieee80211_sta_ht_cap *ht_info)
 -{
 -      struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 -      u8 tx_streams, rx_streams;
 -
 -      ht_info->ht_supported = true;
 -      ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
 -                     IEEE80211_HT_CAP_SM_PS |
 -                     IEEE80211_HT_CAP_SGI_40 |
 -                     IEEE80211_HT_CAP_DSSSCCK40;
 -
 -      ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
 -      ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_8;
 -
 -      /* set up supported mcs set */
 -      memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
 -      tx_streams = !(common->tx_chainmask & (common->tx_chainmask - 1)) ?
 -                   1 : 2;
 -      rx_streams = !(common->rx_chainmask & (common->rx_chainmask - 1)) ?
 -                   1 : 2;
 -
 -      if (tx_streams != rx_streams) {
 -              ath_print(common, ATH_DBG_CONFIG,
 -                        "TX streams %d, RX streams: %d\n",
 -                        tx_streams, rx_streams);
 -              ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF;
 -              ht_info->mcs.tx_params |= ((tx_streams - 1) <<
 -                              IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
 -      }
 -
 -      ht_info->mcs.rx_mask[0] = 0xff;
 -      if (rx_streams >= 2)
 -              ht_info->mcs.rx_mask[1] = 0xff;
 -
 -      ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED;
 -}
 -
  static void ath9k_bss_assoc_info(struct ath_softc *sc,
                                 struct ieee80211_vif *vif,
                                 struct ieee80211_bss_conf *bss_conf)
                 * on the receipt of the first Beacon frame (i.e.,
                 * after time sync with the AP).
                 */
 -              sc->sc_flags |= SC_OP_BEACON_SYNC;
 +              sc->ps_flags |= PS_BEACON_SYNC;
  
                /* Configure the beacon */
                ath_beacon_config(sc, vif);
        }
  }
  
 -/********************************/
 -/*     LED functions          */
 -/********************************/
 -
 -static void ath_led_blink_work(struct work_struct *work)
 -{
 -      struct ath_softc *sc = container_of(work, struct ath_softc,
 -                                          ath_led_blink_work.work);
 -
 -      if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED))
 -              return;
 -
 -      if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) ||
 -          (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE))
 -              ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
 -      else
 -              ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
 -                                (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0);
 -
 -      ieee80211_queue_delayed_work(sc->hw,
 -                                   &sc->ath_led_blink_work,
 -                                   (sc->sc_flags & SC_OP_LED_ON) ?
 -                                      msecs_to_jiffies(sc->led_off_duration) :
 -                                      msecs_to_jiffies(sc->led_on_duration));
 -
 -      sc->led_on_duration = sc->led_on_cnt ?
 -                      max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25) :
 -                      ATH_LED_ON_DURATION_IDLE;
 -      sc->led_off_duration = sc->led_off_cnt ?
 -                      max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10) :
 -                      ATH_LED_OFF_DURATION_IDLE;
 -      sc->led_on_cnt = sc->led_off_cnt = 0;
 -      if (sc->sc_flags & SC_OP_LED_ON)
 -              sc->sc_flags &= ~SC_OP_LED_ON;
 -      else
 -              sc->sc_flags |= SC_OP_LED_ON;
 -}
 -
 -static void ath_led_brightness(struct led_classdev *led_cdev,
 -                             enum led_brightness brightness)
 -{
 -      struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev);
 -      struct ath_softc *sc = led->sc;
 -
 -      switch (brightness) {
 -      case LED_OFF:
 -              if (led->led_type == ATH_LED_ASSOC ||
 -                  led->led_type == ATH_LED_RADIO) {
 -                      ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
 -                              (led->led_type == ATH_LED_RADIO));
 -                      sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
 -                      if (led->led_type == ATH_LED_RADIO)
 -                              sc->sc_flags &= ~SC_OP_LED_ON;
 -              } else {
 -                      sc->led_off_cnt++;
 -              }
 -              break;
 -      case LED_FULL:
 -              if (led->led_type == ATH_LED_ASSOC) {
 -                      sc->sc_flags |= SC_OP_LED_ASSOCIATED;
 -                      ieee80211_queue_delayed_work(sc->hw,
 -                                                   &sc->ath_led_blink_work, 0);
 -              } else if (led->led_type == ATH_LED_RADIO) {
 -                      ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
 -                      sc->sc_flags |= SC_OP_LED_ON;
 -              } else {
 -                      sc->led_on_cnt++;
 -              }
 -              break;
 -      default:
 -              break;
 -      }
 -}
 -
 -static int ath_register_led(struct ath_softc *sc, struct ath_led *led,
 -                          char *trigger)
 -{
 -      int ret;
 -
 -      led->sc = sc;
 -      led->led_cdev.name = led->name;
 -      led->led_cdev.default_trigger = trigger;
 -      led->led_cdev.brightness_set = ath_led_brightness;
 -
 -      ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev);
 -      if (ret)
 -              ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
 -                        "Failed to register led:%s", led->name);
 -      else
 -              led->registered = 1;
 -      return ret;
 -}
 -
 -static void ath_unregister_led(struct ath_led *led)
 -{
 -      if (led->registered) {
 -              led_classdev_unregister(&led->led_cdev);
 -              led->registered = 0;
 -      }
 -}
 -
 -static void ath_deinit_leds(struct ath_softc *sc)
 -{
 -      ath_unregister_led(&sc->assoc_led);
 -      sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
 -      ath_unregister_led(&sc->tx_led);
 -      ath_unregister_led(&sc->rx_led);
 -      ath_unregister_led(&sc->radio_led);
 -      ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
 -}
 -
 -static void ath_init_leds(struct ath_softc *sc)
 -{
 -      char *trigger;
 -      int ret;
 -
 -      if (AR_SREV_9287(sc->sc_ah))
 -              sc->sc_ah->led_pin = ATH_LED_PIN_9287;
 -      else
 -              sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
 -
 -      /* Configure gpio 1 for output */
 -      ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
 -                          AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
 -      /* LED off, active low */
 -      ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
 -
 -      INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work);
 -
 -      trigger = ieee80211_get_radio_led_name(sc->hw);
 -      snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
 -              "ath9k-%s::radio", wiphy_name(sc->hw->wiphy));
 -      ret = ath_register_led(sc, &sc->radio_led, trigger);
 -      sc->radio_led.led_type = ATH_LED_RADIO;
 -      if (ret)
 -              goto fail;
 -
 -      trigger = ieee80211_get_assoc_led_name(sc->hw);
 -      snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name),
 -              "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy));
 -      ret = ath_register_led(sc, &sc->assoc_led, trigger);
 -      sc->assoc_led.led_type = ATH_LED_ASSOC;
 -      if (ret)
 -              goto fail;
 -
 -      trigger = ieee80211_get_tx_led_name(sc->hw);
 -      snprintf(sc->tx_led.name, sizeof(sc->tx_led.name),
 -              "ath9k-%s::tx", wiphy_name(sc->hw->wiphy));
 -      ret = ath_register_led(sc, &sc->tx_led, trigger);
 -      sc->tx_led.led_type = ATH_LED_TX;
 -      if (ret)
 -              goto fail;
 -
 -      trigger = ieee80211_get_rx_led_name(sc->hw);
 -      snprintf(sc->rx_led.name, sizeof(sc->rx_led.name),
 -              "ath9k-%s::rx", wiphy_name(sc->hw->wiphy));
 -      ret = ath_register_led(sc, &sc->rx_led, trigger);
 -      sc->rx_led.led_type = ATH_LED_RX;
 -      if (ret)
 -              goto fail;
 -
 -      return;
 -
 -fail:
 -      cancel_delayed_work_sync(&sc->ath_led_blink_work);
 -      ath_deinit_leds(sc);
 -}
 -
  void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
  {
        struct ath_hw *ah = sc->sc_ah;
@@@ -934,6 -1261,711 +934,6 @@@ void ath_radio_disable(struct ath_soft
        ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
  }
  
 -/*******************/
 -/*    Rfkill     */
 -/*******************/
 -
 -static bool ath_is_rfkill_set(struct ath_softc *sc)
 -{
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      return ath9k_hw_gpio_get(ah, ah->rfkill_gpio) ==
 -                                ah->rfkill_polarity;
 -}
 -
 -static void ath9k_rfkill_poll_state(struct ieee80211_hw *hw)
 -{
 -      struct ath_wiphy *aphy = hw->priv;
 -      struct ath_softc *sc = aphy->sc;
 -      bool blocked = !!ath_is_rfkill_set(sc);
 -
 -      wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
 -}
 -
 -static void ath_start_rfkill_poll(struct ath_softc *sc)
 -{
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
 -              wiphy_rfkill_start_polling(sc->hw->wiphy);
 -}
 -
 -static void ath9k_uninit_hw(struct ath_softc *sc)
 -{
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      BUG_ON(!ah);
 -
 -      ath9k_exit_debug(ah);
 -      ath9k_hw_detach(ah);
 -      sc->sc_ah = NULL;
 -}
 -
 -static void ath_clean_core(struct ath_softc *sc)
 -{
 -      struct ieee80211_hw *hw = sc->hw;
 -      struct ath_hw *ah = sc->sc_ah;
 -      int i = 0;
 -
 -      ath9k_ps_wakeup(sc);
 -
 -      dev_dbg(sc->dev, "Detach ATH hw\n");
 -
 -      ath_deinit_leds(sc);
 -      wiphy_rfkill_stop_polling(sc->hw->wiphy);
 -
 -      for (i = 0; i < sc->num_sec_wiphy; i++) {
 -              struct ath_wiphy *aphy = sc->sec_wiphy[i];
 -              if (aphy == NULL)
 -                      continue;
 -              sc->sec_wiphy[i] = NULL;
 -              ieee80211_unregister_hw(aphy->hw);
 -              ieee80211_free_hw(aphy->hw);
 -      }
 -      ieee80211_unregister_hw(hw);
 -      ath_rx_cleanup(sc);
 -      ath_tx_cleanup(sc);
 -
 -      tasklet_kill(&sc->intr_tq);
 -      tasklet_kill(&sc->bcon_tasklet);
 -
 -      if (!(sc->sc_flags & SC_OP_INVALID))
 -              ath9k_setpower(sc, ATH9K_PM_AWAKE);
 -
 -      /* cleanup tx queues */
 -      for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
 -              if (ATH_TXQ_SETUP(sc, i))
 -                      ath_tx_cleanupq(sc, &sc->tx.txq[i]);
 -
 -      if ((sc->btcoex.no_stomp_timer) &&
 -          ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
 -              ath_gen_timer_free(ah, sc->btcoex.no_stomp_timer);
 -}
 -
 -void ath_detach(struct ath_softc *sc)
 -{
 -      ath_clean_core(sc);
 -      ath9k_uninit_hw(sc);
 -}
 -
 -void ath_cleanup(struct ath_softc *sc)
 -{
 -      struct ath_hw *ah = sc->sc_ah;
 -      struct ath_common *common = ath9k_hw_common(ah);
 -
 -      ath_clean_core(sc);
 -      free_irq(sc->irq, sc);
 -      ath_bus_cleanup(common);
 -      kfree(sc->sec_wiphy);
 -      ieee80211_free_hw(sc->hw);
 -
 -      ath9k_uninit_hw(sc);
 -}
 -
 -static int ath9k_reg_notifier(struct wiphy *wiphy,
 -                            struct regulatory_request *request)
 -{
 -      struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 -      struct ath_wiphy *aphy = hw->priv;
 -      struct ath_softc *sc = aphy->sc;
 -      struct ath_regulatory *reg = ath9k_hw_regulatory(sc->sc_ah);
 -
 -      return ath_reg_notifier_apply(wiphy, request, reg);
 -}
 -
 -/*
 - * Detects if there is any priority bt traffic
 - */
 -static void ath_detect_bt_priority(struct ath_softc *sc)
 -{
 -      struct ath_btcoex *btcoex = &sc->btcoex;
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      if (ath9k_hw_gpio_get(sc->sc_ah, ah->btcoex_hw.btpriority_gpio))
 -              btcoex->bt_priority_cnt++;
 -
 -      if (time_after(jiffies, btcoex->bt_priority_time +
 -                      msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) {
 -              if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
 -                      ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_BTCOEX,
 -                                "BT priority traffic detected");
 -                      sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED;
 -              } else {
 -                      sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED;
 -              }
 -
 -              btcoex->bt_priority_cnt = 0;
 -              btcoex->bt_priority_time = jiffies;
 -      }
 -}
 -
 -/*
 - * Configures appropriate weight based on stomp type.
 - */
 -static void ath9k_btcoex_bt_stomp(struct ath_softc *sc,
 -                                enum ath_stomp_type stomp_type)
 -{
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      switch (stomp_type) {
 -      case ATH_BTCOEX_STOMP_ALL:
 -              ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
 -                                         AR_STOMP_ALL_WLAN_WGHT);
 -              break;
 -      case ATH_BTCOEX_STOMP_LOW:
 -              ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
 -                                         AR_STOMP_LOW_WLAN_WGHT);
 -              break;
 -      case ATH_BTCOEX_STOMP_NONE:
 -              ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
 -                                         AR_STOMP_NONE_WLAN_WGHT);
 -              break;
 -      default:
 -              ath_print(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
 -                        "Invalid Stomptype\n");
 -              break;
 -      }
 -
 -      ath9k_hw_btcoex_enable(ah);
 -}
 -
 -static void ath9k_gen_timer_start(struct ath_hw *ah,
 -                                struct ath_gen_timer *timer,
 -                                u32 timer_next,
 -                                u32 timer_period)
 -{
 -      struct ath_common *common = ath9k_hw_common(ah);
 -      struct ath_softc *sc = (struct ath_softc *) common->priv;
 -
 -      ath9k_hw_gen_timer_start(ah, timer, timer_next, timer_period);
 -
 -      if ((sc->imask & ATH9K_INT_GENTIMER) == 0) {
 -              ath9k_hw_set_interrupts(ah, 0);
 -              sc->imask |= ATH9K_INT_GENTIMER;
 -              ath9k_hw_set_interrupts(ah, sc->imask);
 -      }
 -}
 -
 -static void ath9k_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer)
 -{
 -      struct ath_common *common = ath9k_hw_common(ah);
 -      struct ath_softc *sc = (struct ath_softc *) common->priv;
 -      struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
 -
 -      ath9k_hw_gen_timer_stop(ah, timer);
 -
 -      /* if no timer is enabled, turn off interrupt mask */
 -      if (timer_table->timer_mask.val == 0) {
 -              ath9k_hw_set_interrupts(ah, 0);
 -              sc->imask &= ~ATH9K_INT_GENTIMER;
 -              ath9k_hw_set_interrupts(ah, sc->imask);
 -      }
 -}
 -
 -/*
 - * This is the master bt coex timer which runs for every
 - * 45ms, bt traffic will be given priority during 55% of this
 - * period while wlan gets remaining 45%
 - */
 -static void ath_btcoex_period_timer(unsigned long data)
 -{
 -      struct ath_softc *sc = (struct ath_softc *) data;
 -      struct ath_hw *ah = sc->sc_ah;
 -      struct ath_btcoex *btcoex = &sc->btcoex;
 -
 -      ath_detect_bt_priority(sc);
 -
 -      spin_lock_bh(&btcoex->btcoex_lock);
 -
 -      ath9k_btcoex_bt_stomp(sc, btcoex->bt_stomp_type);
 -
 -      spin_unlock_bh(&btcoex->btcoex_lock);
 -
 -      if (btcoex->btcoex_period != btcoex->btcoex_no_stomp) {
 -              if (btcoex->hw_timer_enabled)
 -                      ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
 -
 -              ath9k_gen_timer_start(ah,
 -                                    btcoex->no_stomp_timer,
 -                                    (ath9k_hw_gettsf32(ah) +
 -                                     btcoex->btcoex_no_stomp),
 -                                     btcoex->btcoex_no_stomp * 10);
 -              btcoex->hw_timer_enabled = true;
 -      }
 -
 -      mod_timer(&btcoex->period_timer, jiffies +
 -                                msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD));
 -}
 -
 -/*
 - * Generic tsf based hw timer which configures weight
 - * registers to time slice between wlan and bt traffic
 - */
 -static void ath_btcoex_no_stomp_timer(void *arg)
 -{
 -      struct ath_softc *sc = (struct ath_softc *)arg;
 -      struct ath_hw *ah = sc->sc_ah;
 -      struct ath_btcoex *btcoex = &sc->btcoex;
 -
 -      ath_print(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
 -                "no stomp timer running \n");
 -
 -      spin_lock_bh(&btcoex->btcoex_lock);
 -
 -      if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW)
 -              ath9k_btcoex_bt_stomp(sc, ATH_BTCOEX_STOMP_NONE);
 -       else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL)
 -              ath9k_btcoex_bt_stomp(sc, ATH_BTCOEX_STOMP_LOW);
 -
 -      spin_unlock_bh(&btcoex->btcoex_lock);
 -}
 -
 -static int ath_init_btcoex_timer(struct ath_softc *sc)
 -{
 -      struct ath_btcoex *btcoex = &sc->btcoex;
 -
 -      btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000;
 -      btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
 -              btcoex->btcoex_period / 100;
 -
 -      setup_timer(&btcoex->period_timer, ath_btcoex_period_timer,
 -                      (unsigned long) sc);
 -
 -      spin_lock_init(&btcoex->btcoex_lock);
 -
 -      btcoex->no_stomp_timer = ath_gen_timer_alloc(sc->sc_ah,
 -                      ath_btcoex_no_stomp_timer,
 -                      ath_btcoex_no_stomp_timer,
 -                      (void *) sc, AR_FIRST_NDP_TIMER);
 -
 -      if (!btcoex->no_stomp_timer)
 -              return -ENOMEM;
 -
 -      return 0;
 -}
 -
 -/*
 - * Read and write, they both share the same lock. We do this to serialize
 - * reads and writes on Atheros 802.11n PCI devices only. This is required
 - * as the FIFO on these devices can only accept sanely 2 requests. After
 - * that the device goes bananas. Serializing the reads/writes prevents this
 - * from happening.
 - */
 -
 -static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset)
 -{
 -      struct ath_hw *ah = (struct ath_hw *) hw_priv;
 -      struct ath_common *common = ath9k_hw_common(ah);
 -      struct ath_softc *sc = (struct ath_softc *) common->priv;
 -
 -      if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
 -              unsigned long flags;
 -              spin_lock_irqsave(&sc->sc_serial_rw, flags);
 -              iowrite32(val, sc->mem + reg_offset);
 -              spin_unlock_irqrestore(&sc->sc_serial_rw, flags);
 -      } else
 -              iowrite32(val, sc->mem + reg_offset);
 -}
 -
 -static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)
 -{
 -      struct ath_hw *ah = (struct ath_hw *) hw_priv;
 -      struct ath_common *common = ath9k_hw_common(ah);
 -      struct ath_softc *sc = (struct ath_softc *) common->priv;
 -      u32 val;
 -
 -      if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
 -              unsigned long flags;
 -              spin_lock_irqsave(&sc->sc_serial_rw, flags);
 -              val = ioread32(sc->mem + reg_offset);
 -              spin_unlock_irqrestore(&sc->sc_serial_rw, flags);
 -      } else
 -              val = ioread32(sc->mem + reg_offset);
 -      return val;
 -}
 -
 -static const struct ath_ops ath9k_common_ops = {
 -      .read = ath9k_ioread32,
 -      .write = ath9k_iowrite32,
 -};
 -
 -/*
 - * Initialize and fill ath_softc, ath_sofct is the
 - * "Software Carrier" struct. Historically it has existed
 - * to allow the separation between hardware specific
 - * variables (now in ath_hw) and driver specific variables.
 - */
 -static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
 -                        const struct ath_bus_ops *bus_ops)
 -{
 -      struct ath_hw *ah = NULL;
 -      struct ath_common *common;
 -      int r = 0, i;
 -      int csz = 0;
 -      int qnum;
 -
 -      /* XXX: hardware will not be ready until ath_open() being called */
 -      sc->sc_flags |= SC_OP_INVALID;
 -
 -      spin_lock_init(&sc->wiphy_lock);
 -      spin_lock_init(&sc->sc_resetlock);
 -      spin_lock_init(&sc->sc_serial_rw);
 -      spin_lock_init(&sc->ani_lock);
 -      spin_lock_init(&sc->sc_pm_lock);
 -      mutex_init(&sc->mutex);
 -      tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
 -      tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
 -                   (unsigned long)sc);
 -
 -      ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL);
 -      if (!ah)
 -              return -ENOMEM;
 -
 -      ah->hw_version.devid = devid;
 -      ah->hw_version.subsysid = subsysid;
 -      sc->sc_ah = ah;
 -
 -      common = ath9k_hw_common(ah);
 -      common->ops = &ath9k_common_ops;
 -      common->bus_ops = bus_ops;
 -      common->ah = ah;
 -      common->hw = sc->hw;
 -      common->priv = sc;
 -      common->debug_mask = ath9k_debug;
 -
 -      /*
 -       * Cache line size is used to size and align various
 -       * structures used to communicate with the hardware.
 -       */
 -      ath_read_cachesize(common, &csz);
 -      /* XXX assert csz is non-zero */
 -      common->cachelsz = csz << 2;    /* convert to bytes */
 -
 -      r = ath9k_hw_init(ah);
 -      if (r) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to initialize hardware; "
 -                        "initialization status: %d\n", r);
 -              goto bad_free_hw;
 -      }
 -
 -      if (ath9k_init_debug(ah) < 0) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to create debugfs files\n");
 -              goto bad_free_hw;
 -      }
 -
 -      /* Get the hardware key cache size. */
 -      common->keymax = ah->caps.keycache_size;
 -      if (common->keymax > ATH_KEYMAX) {
 -              ath_print(common, ATH_DBG_ANY,
 -                        "Warning, using only %u entries in %u key cache\n",
 -                        ATH_KEYMAX, common->keymax);
 -              common->keymax = ATH_KEYMAX;
 -      }
 -
 -      /*
 -       * Reset the key cache since some parts do not
 -       * reset the contents on initial power up.
 -       */
 -      for (i = 0; i < common->keymax; i++)
 -              ath9k_hw_keyreset(ah, (u16) i);
 -
 -      /* default to MONITOR mode */
 -      sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR;
 -
 -      /*
 -       * Allocate hardware transmit queues: one queue for
 -       * beacon frames and one data queue for each QoS
 -       * priority.  Note that the hal handles reseting
 -       * these queues at the needed time.
 -       */
 -      sc->beacon.beaconq = ath9k_hw_beaconq_setup(ah);
 -      if (sc->beacon.beaconq == -1) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to setup a beacon xmit queue\n");
 -              r = -EIO;
 -              goto bad2;
 -      }
 -      sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0);
 -      if (sc->beacon.cabq == NULL) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to setup CAB xmit queue\n");
 -              r = -EIO;
 -              goto bad2;
 -      }
 -
 -      sc->config.cabqReadytime = ATH_CABQ_READY_TIME;
 -      ath_cabq_update(sc);
 -
 -      for (i = 0; i < ARRAY_SIZE(sc->tx.hwq_map); i++)
 -              sc->tx.hwq_map[i] = -1;
 -
 -      /* Setup data queues */
 -      /* NB: ensure BK queue is the lowest priority h/w queue */
 -      if (!ath_tx_setup(sc, ATH9K_WME_AC_BK)) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to setup xmit queue for BK traffic\n");
 -              r = -EIO;
 -              goto bad2;
 -      }
 -
 -      if (!ath_tx_setup(sc, ATH9K_WME_AC_BE)) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to setup xmit queue for BE traffic\n");
 -              r = -EIO;
 -              goto bad2;
 -      }
 -      if (!ath_tx_setup(sc, ATH9K_WME_AC_VI)) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to setup xmit queue for VI traffic\n");
 -              r = -EIO;
 -              goto bad2;
 -      }
 -      if (!ath_tx_setup(sc, ATH9K_WME_AC_VO)) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "Unable to setup xmit queue for VO traffic\n");
 -              r = -EIO;
 -              goto bad2;
 -      }
 -
 -      /* Initializes the noise floor to a reasonable default value.
 -       * Later on this will be updated during ANI processing. */
 -
 -      common->ani.noise_floor = ATH_DEFAULT_NOISE_FLOOR;
 -      setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc);
 -
 -      if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
 -                                 ATH9K_CIPHER_TKIP, NULL)) {
 -              /*
 -               * Whether we should enable h/w TKIP MIC.
 -               * XXX: if we don't support WME TKIP MIC, then we wouldn't
 -               * report WMM capable, so it's always safe to turn on
 -               * TKIP MIC in this case.
 -               */
 -              ath9k_hw_setcapability(sc->sc_ah, ATH9K_CAP_TKIP_MIC,
 -                                     0, 1, NULL);
 -      }
 -
 -      /*
 -       * Check whether the separate key cache entries
 -       * are required to handle both tx+rx MIC keys.
 -       * With split mic keys the number of stations is limited
 -       * to 27 otherwise 59.
 -       */
 -      if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
 -                                 ATH9K_CIPHER_TKIP, NULL)
 -          && ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
 -                                    ATH9K_CIPHER_MIC, NULL)
 -          && ath9k_hw_getcapability(ah, ATH9K_CAP_TKIP_SPLIT,
 -                                    0, NULL))
 -              common->splitmic = 1;
 -
 -      /* turn on mcast key search if possible */
 -      if (!ath9k_hw_getcapability(ah, ATH9K_CAP_MCAST_KEYSRCH, 0, NULL))
 -              (void)ath9k_hw_setcapability(ah, ATH9K_CAP_MCAST_KEYSRCH, 1,
 -                                           1, NULL);
 -
 -      sc->config.txpowlimit = ATH_TXPOWER_MAX;
 -
 -      /* 11n Capabilities */
 -      if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
 -              sc->sc_flags |= SC_OP_TXAGGR;
 -              sc->sc_flags |= SC_OP_RXAGGR;
 -      }
 -
 -      common->tx_chainmask = ah->caps.tx_chainmask;
 -      common->rx_chainmask = ah->caps.rx_chainmask;
 -
 -      ath9k_hw_setcapability(ah, ATH9K_CAP_DIVERSITY, 1, true, NULL);
 -      sc->rx.defant = ath9k_hw_getdefantenna(ah);
 -
 -      if (ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
 -              memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
 -
 -      sc->beacon.slottime = ATH9K_SLOT_TIME_9;        /* default to short slot time */
 -
 -      /* initialize beacon slots */
 -      for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) {
 -              sc->beacon.bslot[i] = NULL;
 -              sc->beacon.bslot_aphy[i] = NULL;
 -      }
 -
 -      /* setup channels and rates */
 -
 -      if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
 -              sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
 -              sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
 -              sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
 -                      ARRAY_SIZE(ath9k_2ghz_chantable);
 -              sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
 -              sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
 -                      ARRAY_SIZE(ath9k_legacy_rates);
 -      }
 -
 -      if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
 -              sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
 -              sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
 -              sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
 -                      ARRAY_SIZE(ath9k_5ghz_chantable);
 -              sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
 -                      ath9k_legacy_rates + 4;
 -              sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
 -                      ARRAY_SIZE(ath9k_legacy_rates) - 4;
 -      }
 -
 -      switch (ah->btcoex_hw.scheme) {
 -      case ATH_BTCOEX_CFG_NONE:
 -              break;
 -      case ATH_BTCOEX_CFG_2WIRE:
 -              ath9k_hw_btcoex_init_2wire(ah);
 -              break;
 -      case ATH_BTCOEX_CFG_3WIRE:
 -              ath9k_hw_btcoex_init_3wire(ah);
 -              r = ath_init_btcoex_timer(sc);
 -              if (r)
 -                      goto bad2;
 -              qnum = ath_tx_get_qnum(sc, ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE);
 -              ath9k_hw_init_btcoex_hw(ah, qnum);
 -              sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
 -              break;
 -      default:
 -              WARN_ON(1);
 -              break;
 -      }
 -
 -      return 0;
 -bad2:
 -      /* cleanup tx queues */
 -      for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
 -              if (ATH_TXQ_SETUP(sc, i))
 -                      ath_tx_cleanupq(sc, &sc->tx.txq[i]);
 -
 -bad_free_hw:
 -      ath9k_uninit_hw(sc);
 -      return r;
 -}
 -
 -void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 -{
 -      hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
 -              IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
 -              IEEE80211_HW_SIGNAL_DBM |
 -              IEEE80211_HW_AMPDU_AGGREGATION |
 -              IEEE80211_HW_SUPPORTS_PS |
 -              IEEE80211_HW_PS_NULLFUNC_STACK |
 -              IEEE80211_HW_SPECTRUM_MGMT;
 -
 -      if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || modparam_nohwcrypt)
 -              hw->flags |= IEEE80211_HW_MFP_CAPABLE;
 -
 -      hw->wiphy->interface_modes =
 -              BIT(NL80211_IFTYPE_AP) |
 -              BIT(NL80211_IFTYPE_STATION) |
 -              BIT(NL80211_IFTYPE_ADHOC) |
 -              BIT(NL80211_IFTYPE_MESH_POINT);
 -
 -      hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
 -
 -      hw->queues = 4;
 -      hw->max_rates = 4;
 -      hw->channel_change_time = 5000;
 -      hw->max_listen_interval = 10;
 -      /* Hardware supports 10 but we use 4 */
 -      hw->max_rate_tries = 4;
 -      hw->sta_data_size = sizeof(struct ath_node);
 -      hw->vif_data_size = sizeof(struct ath_vif);
 -
 -      hw->rate_control_algorithm = "ath9k_rate_control";
 -
 -      if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes))
 -              hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
 -                      &sc->sbands[IEEE80211_BAND_2GHZ];
 -      if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes))
 -              hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
 -                      &sc->sbands[IEEE80211_BAND_5GHZ];
 -}
 -
 -/* Device driver core initialization */
 -int ath_init_device(u16 devid, struct ath_softc *sc, u16 subsysid,
 -                  const struct ath_bus_ops *bus_ops)
 -{
 -      struct ieee80211_hw *hw = sc->hw;
 -      struct ath_common *common;
 -      struct ath_hw *ah;
 -      int error = 0, i;
 -      struct ath_regulatory *reg;
 -
 -      dev_dbg(sc->dev, "Attach ATH hw\n");
 -
 -      error = ath_init_softc(devid, sc, subsysid, bus_ops);
 -      if (error != 0)
 -              return error;
 -
 -      ah = sc->sc_ah;
 -      common = ath9k_hw_common(ah);
 -
 -      /* get mac address from hardware and set in mac80211 */
 -
 -      SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
 -
 -      ath_set_hw_capab(sc, hw);
 -
 -      error = ath_regd_init(&common->regulatory, sc->hw->wiphy,
 -                            ath9k_reg_notifier);
 -      if (error)
 -              return error;
 -
 -      reg = &common->regulatory;
 -
 -      if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
 -              if (test_bit(ATH9K_MODE_11G, ah->caps.wireless_modes))
 -                      setup_ht_cap(sc,
 -                                   &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
 -              if (test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes))
 -                      setup_ht_cap(sc,
 -                                   &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
 -      }
 -
 -      /* initialize tx/rx engine */
 -      error = ath_tx_init(sc, ATH_TXBUF);
 -      if (error != 0)
 -              goto error_attach;
 -
 -      error = ath_rx_init(sc, ATH_RXBUF);
 -      if (error != 0)
 -              goto error_attach;
 -
 -      INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
 -      INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
 -      sc->wiphy_scheduler_int = msecs_to_jiffies(500);
 -
 -      error = ieee80211_register_hw(hw);
 -
 -      if (!ath_is_world_regd(reg)) {
 -              error = regulatory_hint(hw->wiphy, reg->alpha2);
 -              if (error)
 -                      goto error_attach;
 -      }
 -
 -      /* Initialize LED control */
 -      ath_init_leds(sc);
 -
 -      ath_start_rfkill_poll(sc);
 -
 -      return 0;
 -
 -error_attach:
 -      /* cleanup tx queues */
 -      for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
 -              if (ATH_TXQ_SETUP(sc, i))
 -                      ath_tx_cleanupq(sc, &sc->tx.txq[i]);
 -
 -      ath9k_uninit_hw(sc);
 -
 -      return error;
 -}
 -
  int ath_reset(struct ath_softc *sc, bool retry_tx)
  {
        struct ath_hw *ah = sc->sc_ah;
        /* Stop ANI */
        del_timer_sync(&common->ani.timer);
  
 +      ieee80211_stop_queues(hw);
 +
        ath9k_hw_set_interrupts(ah, 0);
        ath_drain_all_txq(sc, retry_tx);
        ath_stoprecv(sc);
                }
        }
  
 +      ieee80211_wake_queues(hw);
 +
        /* Start ANI */
        ath_start_ani(common);
  
        return r;
  }
  
 -/*
 - *  This function will allocate both the DMA descriptor structure, and the
 - *  buffers it contains.  These are used to contain the descriptors used
 - *  by the system.
 -*/
 -int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
 -                    struct list_head *head, const char *name,
 -                    int nbuf, int ndesc)
 -{
 -#define       DS2PHYS(_dd, _ds)                                               \
 -      ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
 -#define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0)
 -#define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096)
 -      struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 -      struct ath_desc *ds;
 -      struct ath_buf *bf;
 -      int i, bsize, error;
 -
 -      ath_print(common, ATH_DBG_CONFIG, "%s DMA: %u buffers %u desc/buf\n",
 -                name, nbuf, ndesc);
 -
 -      INIT_LIST_HEAD(head);
 -      /* ath_desc must be a multiple of DWORDs */
 -      if ((sizeof(struct ath_desc) % 4) != 0) {
 -              ath_print(common, ATH_DBG_FATAL,
 -                        "ath_desc not DWORD aligned\n");
 -              BUG_ON((sizeof(struct ath_desc) % 4) != 0);
 -              error = -ENOMEM;
 -              goto fail;
 -      }
 -
 -      dd->dd_desc_len = sizeof(struct ath_desc) * nbuf * ndesc;
 -
 -      /*
 -       * Need additional DMA memory because we can't use
 -       * descriptors that cross the 4K page boundary. Assume
 -       * one skipped descriptor per 4K page.
 -       */
 -      if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) {
 -              u32 ndesc_skipped =
 -                      ATH_DESC_4KB_BOUND_NUM_SKIPPED(dd->dd_desc_len);
 -              u32 dma_len;
 -
 -              while (ndesc_skipped) {
 -                      dma_len = ndesc_skipped * sizeof(struct ath_desc);
 -                      dd->dd_desc_len += dma_len;
 -
 -                      ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dma_len);
 -              };
 -      }
 -
 -      /* allocate descriptors */
 -      dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len,
 -                                       &dd->dd_desc_paddr, GFP_KERNEL);
 -      if (dd->dd_desc == NULL) {
 -              error = -ENOMEM;
 -              goto fail;
 -      }
 -      ds = dd->dd_desc;
 -      ath_print(common, ATH_DBG_CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n",
 -                name, ds, (u32) dd->dd_desc_len,
 -                ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
 -
 -      /* allocate buffers */
 -      bsize = sizeof(struct ath_buf) * nbuf;
 -      bf = kzalloc(bsize, GFP_KERNEL);
 -      if (bf == NULL) {
 -              error = -ENOMEM;
 -              goto fail2;
 -      }
 -      dd->dd_bufptr = bf;
 -
 -      for (i = 0; i < nbuf; i++, bf++, ds += ndesc) {
 -              bf->bf_desc = ds;
 -              bf->bf_daddr = DS2PHYS(dd, ds);
 -
 -              if (!(sc->sc_ah->caps.hw_caps &
 -                    ATH9K_HW_CAP_4KB_SPLITTRANS)) {
 -                      /*
 -                       * Skip descriptor addresses which can cause 4KB
 -                       * boundary crossing (addr + length) with a 32 dword
 -                       * descriptor fetch.
 -                       */
 -                      while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
 -                              BUG_ON((caddr_t) bf->bf_desc >=
 -                                     ((caddr_t) dd->dd_desc +
 -                                      dd->dd_desc_len));
 -
 -                              ds += ndesc;
 -                              bf->bf_desc = ds;
 -                              bf->bf_daddr = DS2PHYS(dd, ds);
 -                      }
 -              }
 -              list_add_tail(&bf->list, head);
 -      }
 -      return 0;
 -fail2:
 -      dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
 -                        dd->dd_desc_paddr);
 -fail:
 -      memset(dd, 0, sizeof(*dd));
 -      return error;
 -#undef ATH_DESC_4KB_BOUND_CHECK
 -#undef ATH_DESC_4KB_BOUND_NUM_SKIPPED
 -#undef DS2PHYS
 -}
 -
 -void ath_descdma_cleanup(struct ath_softc *sc,
 -                       struct ath_descdma *dd,
 -                       struct list_head *head)
 -{
 -      dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
 -                        dd->dd_desc_paddr);
 -
 -      INIT_LIST_HEAD(head);
 -      kfree(dd->dd_bufptr);
 -      memset(dd, 0, sizeof(*dd));
 -}
 -
  int ath_get_hal_qnum(u16 queue, struct ath_softc *sc)
  {
        int qnum;
@@@ -1073,6 -2220,28 +1073,6 @@@ void ath9k_update_ichannel(struct ath_s
  /* mac80211 callbacks */
  /**********************/
  
 -/*
 - * (Re)start btcoex timers
 - */
 -static void ath9k_btcoex_timer_resume(struct ath_softc *sc)
 -{
 -      struct ath_btcoex *btcoex = &sc->btcoex;
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      ath_print(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
 -                "Starting btcoex timers");
 -
 -      /* make sure duty cycle timer is also stopped when resuming */
 -      if (btcoex->hw_timer_enabled)
 -              ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
 -
 -      btcoex->bt_priority_cnt = 0;
 -      btcoex->bt_priority_time = jiffies;
 -      sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED;
 -
 -      mod_timer(&btcoex->period_timer, jiffies);
 -}
 -
  static int ath9k_start(struct ieee80211_hw *hw)
  {
        struct ath_wiphy *aphy = hw->priv;
@@@ -1242,11 -2411,11 +1242,11 @@@ static int ath9k_tx(struct ieee80211_h
                if (ieee80211_is_pspoll(hdr->frame_control)) {
                        ath_print(common, ATH_DBG_PS,
                                  "Sending PS-Poll to pick a buffered frame\n");
 -                      sc->sc_flags |= SC_OP_WAIT_FOR_PSPOLL_DATA;
 +                      sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
                } else {
                        ath_print(common, ATH_DBG_PS,
                                  "Wake up to complete TX\n");
 -                      sc->sc_flags |= SC_OP_WAIT_FOR_TX_ACK;
 +                      sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
                }
                /*
                 * The actual restore operation will happen only after
@@@ -1299,6 -2468,22 +1299,6 @@@ exit
        return 0;
  }
  
 -/*
 - * Pause btcoex timer and bt duty cycle timer
 - */
 -static void ath9k_btcoex_timer_pause(struct ath_softc *sc)
 -{
 -      struct ath_btcoex *btcoex = &sc->btcoex;
 -      struct ath_hw *ah = sc->sc_ah;
 -
 -      del_timer_sync(&btcoex->period_timer);
 -
 -      if (btcoex->hw_timer_enabled)
 -              ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
 -
 -      btcoex->hw_timer_enabled = false;
 -}
 -
  static void ath9k_stop(struct ieee80211_hw *hw)
  {
        struct ath_wiphy *aphy = hw->priv;
  }
  
  static int ath9k_add_interface(struct ieee80211_hw *hw,
 -                             struct ieee80211_if_init_conf *conf)
 +                             struct ieee80211_vif *vif)
  {
        struct ath_wiphy *aphy = hw->priv;
        struct ath_softc *sc = aphy->sc;
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 -      struct ath_vif *avp = (void *)conf->vif->drv_priv;
 +      struct ath_vif *avp = (void *)vif->drv_priv;
        enum nl80211_iftype ic_opmode = NL80211_IFTYPE_UNSPECIFIED;
        int ret = 0;
  
                goto out;
        }
  
 -      switch (conf->type) {
 +      switch (vif->type) {
        case NL80211_IFTYPE_STATION:
                ic_opmode = NL80211_IFTYPE_STATION;
                break;
                        ret = -ENOBUFS;
                        goto out;
                }
 -              ic_opmode = conf->type;
 +              ic_opmode = vif->type;
                break;
        default:
                ath_print(common, ATH_DBG_FATAL,
 -                      "Interface type %d not yet supported\n", conf->type);
 +                      "Interface type %d not yet supported\n", vif->type);
                ret = -EOPNOTSUPP;
                goto out;
        }
         * Enable MIB interrupts when there are hardware phy counters.
         * Note we only do this (at the moment) for station mode.
         */
 -      if ((conf->type == NL80211_IFTYPE_STATION) ||
 -          (conf->type == NL80211_IFTYPE_ADHOC) ||
 -          (conf->type == NL80211_IFTYPE_MESH_POINT)) {
 +      if ((vif->type == NL80211_IFTYPE_STATION) ||
 +          (vif->type == NL80211_IFTYPE_ADHOC) ||
 +          (vif->type == NL80211_IFTYPE_MESH_POINT)) {
                sc->imask |= ATH9K_INT_MIB;
                sc->imask |= ATH9K_INT_TSFOOR;
        }
  
        ath9k_hw_set_interrupts(sc->sc_ah, sc->imask);
  
 -      if (conf->type == NL80211_IFTYPE_AP    ||
 -          conf->type == NL80211_IFTYPE_ADHOC ||
 -          conf->type == NL80211_IFTYPE_MONITOR)
 +      if (vif->type == NL80211_IFTYPE_AP    ||
 +          vif->type == NL80211_IFTYPE_ADHOC ||
 +          vif->type == NL80211_IFTYPE_MONITOR)
                ath_start_ani(common);
  
  out:
  }
  
  static void ath9k_remove_interface(struct ieee80211_hw *hw,
 -                                 struct ieee80211_if_init_conf *conf)
 +                                 struct ieee80211_vif *vif)
  {
        struct ath_wiphy *aphy = hw->priv;
        struct ath_softc *sc = aphy->sc;
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 -      struct ath_vif *avp = (void *)conf->vif->drv_priv;
 +      struct ath_vif *avp = (void *)vif->drv_priv;
        int i;
  
        ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n");
            (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) {
                ath9k_ps_wakeup(sc);
                ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
                ath9k_ps_restore(sc);
        }
  
+       ath_beacon_return(sc, avp);
        sc->sc_flags &= ~SC_OP_BEACONS;
  
        for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) {
 -              if (sc->beacon.bslot[i] == conf->vif) {
 +              if (sc->beacon.bslot[i] == vif) {
                        printk(KERN_DEBUG "%s: vif had allocated beacon "
                               "slot\n", __func__);
                        sc->beacon.bslot[i] = NULL;
@@@ -1542,7 -2727,7 +1542,7 @@@ static int ath9k_config(struct ieee8021
         */
        if (changed & IEEE80211_CONF_CHANGE_PS) {
                if (conf->flags & IEEE80211_CONF_PS) {
 -                      sc->sc_flags |= SC_OP_PS_ENABLED;
 +                      sc->ps_flags |= PS_ENABLED;
                        if (!(ah->caps.hw_caps &
                              ATH9K_HW_CAP_AUTOSLEEP)) {
                                if ((sc->imask & ATH9K_INT_TIM_TIMER) == 0) {
                         * At this point we know hardware has received an ACK
                         * of a previously sent null data frame.
                         */
 -                      if ((sc->sc_flags & SC_OP_NULLFUNC_COMPLETED)) {
 -                              sc->sc_flags &= ~SC_OP_NULLFUNC_COMPLETED;
 +                      if ((sc->ps_flags & PS_NULLFUNC_COMPLETED)) {
 +                              sc->ps_flags &= ~PS_NULLFUNC_COMPLETED;
                                sc->ps_enabled = true;
                                ath9k_hw_setrxabort(sc->sc_ah, 1);
                          }
                } else {
                        sc->ps_enabled = false;
 -                      sc->sc_flags &= ~(SC_OP_PS_ENABLED |
 -                                        SC_OP_NULLFUNC_COMPLETED);
 +                      sc->ps_flags &= ~(PS_ENABLED |
 +                                        PS_NULLFUNC_COMPLETED);
                        ath9k_setpower(sc, ATH9K_PM_AWAKE);
                        if (!(ah->caps.hw_caps &
                              ATH9K_HW_CAP_AUTOSLEEP)) {
                                ath9k_hw_setrxabort(sc->sc_ah, 0);
 -                              sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON |
 -                                                SC_OP_WAIT_FOR_CAB |
 -                                                SC_OP_WAIT_FOR_PSPOLL_DATA |
 -                                                SC_OP_WAIT_FOR_TX_ACK);
 +                              sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
 +                                                PS_WAIT_FOR_CAB |
 +                                                PS_WAIT_FOR_PSPOLL_DATA |
 +                                                PS_WAIT_FOR_TX_ACK);
                                if (sc->imask & ATH9K_INT_TIM_TIMER) {
                                        sc->imask &= ~ATH9K_INT_TIM_TIMER;
                                        ath9k_hw_set_interrupts(sc->sc_ah,
                }
        }
  
 +      if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
 +              if (conf->flags & IEEE80211_CONF_MONITOR) {
 +                      ath_print(common, ATH_DBG_CONFIG,
 +                                "HW opmode set to Monitor mode\n");
 +                      sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR;
 +              }
 +      }
 +
        if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
                struct ieee80211_channel *curchan = hw->conf.channel;
                int pos = curchan->hw_value;
@@@ -1789,7 -2966,6 +1789,7 @@@ static void ath9k_bss_info_changed(stru
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
        struct ath_vif *avp = (void *)vif->drv_priv;
 +      int slottime;
        int error;
  
        mutex_lock(&sc->mutex);
                        ath_beacon_config(sc, vif);
        }
  
 +      if (changed & BSS_CHANGED_ERP_SLOT) {
 +              if (bss_conf->use_short_slot)
 +                      slottime = 9;
 +              else
 +                      slottime = 20;
 +              if (vif->type == NL80211_IFTYPE_AP) {
 +                      /*
 +                       * Defer update, so that connected stations can adjust
 +                       * their settings at the same time.
 +                       * See beacon.c for more details
 +                       */
 +                      sc->beacon.slottime = slottime;
 +                      sc->beacon.updateslot = UPDATE;
 +              } else {
 +                      ah->slottime = slottime;
 +                      ath9k_hw_init_global_settings(ah);
 +              }
 +      }
 +
        /* Disable transmission of beacons */
        if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon)
                ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
@@@ -1976,7 -3133,6 +1976,7 @@@ static void ath9k_sw_scan_start(struct 
  {
        struct ath_wiphy *aphy = hw->priv;
        struct ath_softc *sc = aphy->sc;
 +      struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  
        mutex_lock(&sc->mutex);
        if (ath9k_wiphy_scanning(sc)) {
  
        aphy->state = ATH_WIPHY_SCAN;
        ath9k_wiphy_pause_all_forced(sc, aphy);
 -
 -      spin_lock_bh(&sc->ani_lock);
        sc->sc_flags |= SC_OP_SCANNING;
 -      spin_unlock_bh(&sc->ani_lock);
 +      del_timer_sync(&common->ani.timer);
 +      cancel_delayed_work_sync(&sc->tx_complete_work);
        mutex_unlock(&sc->mutex);
  }
  
@@@ -2002,30 -3159,17 +2002,30 @@@ static void ath9k_sw_scan_complete(stru
  {
        struct ath_wiphy *aphy = hw->priv;
        struct ath_softc *sc = aphy->sc;
 +      struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  
        mutex_lock(&sc->mutex);
        aphy->state = ATH_WIPHY_ACTIVE;
        sc->sc_flags &= ~SC_OP_SCANNING;
        sc->sc_flags |= SC_OP_FULL_RESET;
 -      spin_unlock_bh(&sc->ani_lock);
 +      ath_start_ani(common);
 +      ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
        ath_beacon_config(sc, NULL);
        mutex_unlock(&sc->mutex);
  }
  
 +static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
 +{
 +      struct ath_wiphy *aphy = hw->priv;
 +      struct ath_softc *sc = aphy->sc;
 +      struct ath_hw *ah = sc->sc_ah;
 +
 +      mutex_lock(&sc->mutex);
 +      ah->coverage_class = coverage_class;
 +      ath9k_hw_init_global_settings(ah);
 +      mutex_unlock(&sc->mutex);
 +}
 +
  struct ieee80211_ops ath9k_ops = {
        .tx                 = ath9k_tx,
        .start              = ath9k_start,
        .sw_scan_start      = ath9k_sw_scan_start,
        .sw_scan_complete   = ath9k_sw_scan_complete,
        .rfkill_poll        = ath9k_rfkill_poll_state,
 +      .set_coverage_class = ath9k_set_coverage_class,
  };
 -
 -static int __init ath9k_init(void)
 -{
 -      int error;
 -
 -      /* Register rate control algorithm */
 -      error = ath_rate_control_register();
 -      if (error != 0) {
 -              printk(KERN_ERR
 -                      "ath9k: Unable to register rate control "
 -                      "algorithm: %d\n",
 -                      error);
 -              goto err_out;
 -      }
 -
 -      error = ath9k_debug_create_root();
 -      if (error) {
 -              printk(KERN_ERR
 -                      "ath9k: Unable to create debugfs root: %d\n",
 -                      error);
 -              goto err_rate_unregister;
 -      }
 -
 -      error = ath_pci_init();
 -      if (error < 0) {
 -              printk(KERN_ERR
 -                      "ath9k: No PCI devices found, driver not installed.\n");
 -              error = -ENODEV;
 -              goto err_remove_root;
 -      }
 -
 -      error = ath_ahb_init();
 -      if (error < 0) {
 -              error = -ENODEV;
 -              goto err_pci_exit;
 -      }
 -
 -      return 0;
 -
 - err_pci_exit:
 -      ath_pci_exit();
 -
 - err_remove_root:
 -      ath9k_debug_remove_root();
 - err_rate_unregister:
 -      ath_rate_control_unregister();
 - err_out:
 -      return error;
 -}
 -module_init(ath9k_init);
 -
 -static void __exit ath9k_exit(void)
 -{
 -      ath_ahb_exit();
 -      ath_pci_exit();
 -      ath9k_debug_remove_root();
 -      ath_rate_control_unregister();
 -      printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 -}
 -module_exit(ath9k_exit);
diff --combined net/8021q/vlan_dev.c
@@@ -163,7 -163,7 +163,7 @@@ int vlan_skb_recv(struct sk_buff *skb, 
                goto err_unlock;
        }
  
-       rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats,
+       rx_stats = per_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats,
                               smp_processor_id());
        rx_stats->rx_packets++;
        rx_stats->rx_bytes += skb->len;
@@@ -263,10 -263,11 +263,10 @@@ static int vlan_dev_hard_header(struct 
                vhdr->h_vlan_TCI = htons(vlan_tci);
  
                /*
 -               *  Set the protocol type. For a packet of type ETH_P_802_3 we
 -               *  put the length in here instead. It is up to the 802.2
 -               *  layer to carry protocol information.
 +               *  Set the protocol type. For a packet of type ETH_P_802_3/2 we
 +               *  put the length in here instead.
                 */
 -              if (type != ETH_P_802_3)
 +              if (type != ETH_P_802_3 && type != ETH_P_802_2)
                        vhdr->h_vlan_encapsulated_proto = htons(type);
                else
                        vhdr->h_vlan_encapsulated_proto = htons(len);
@@@ -25,12 -25,10 +25,12 @@@ static inline void trace_ ## name(proto
  #define STA_PR_FMT    " sta:%pM"
  #define STA_PR_ARG    __entry->sta_addr
  
 -#define VIF_ENTRY     __field(enum nl80211_iftype, vif_type) __field(void *, vif)
 -#define VIF_ASSIGN    __entry->vif_type = vif ? vif->type : 0; __entry->vif = vif
 -#define VIF_PR_FMT    " vif:%p(%d)"
 -#define VIF_PR_ARG    __entry->vif, __entry->vif_type
 +#define VIF_ENTRY     __field(enum nl80211_iftype, vif_type) __field(void *, sdata) \
 +                      __string(vif_name, sdata->dev ? sdata->dev->name : "<nodev>")
 +#define VIF_ASSIGN    __entry->vif_type = sdata->vif.type; __entry->sdata = sdata; \
 +                      __assign_str(vif_name, sdata->dev ? sdata->dev->name : "<nodev>")
 +#define VIF_PR_FMT    " vif:%s(%d)"
 +#define VIF_PR_ARG    __get_str(vif_name), __entry->vif_type
  
  TRACE_EVENT(drv_start,
        TP_PROTO(struct ieee80211_local *local, int ret),
@@@ -72,10 -70,11 +72,10 @@@ TRACE_EVENT(drv_stop
  
  TRACE_EVENT(drv_add_interface,
        TP_PROTO(struct ieee80211_local *local,
 -               const u8 *addr,
 -               struct ieee80211_vif *vif,
 +               struct ieee80211_sub_if_data *sdata,
                 int ret),
  
 -      TP_ARGS(local, addr, vif, ret),
 +      TP_ARGS(local, sdata, ret),
  
        TP_STRUCT__entry(
                LOCAL_ENTRY
@@@ -87,7 -86,7 +87,7 @@@
        TP_fast_assign(
                LOCAL_ASSIGN;
                VIF_ASSIGN;
 -              memcpy(__entry->addr, addr, 6);
 +              memcpy(__entry->addr, sdata->vif.addr, 6);
                __entry->ret = ret;
        ),
  
  );
  
  TRACE_EVENT(drv_remove_interface,
 -      TP_PROTO(struct ieee80211_local *local,
 -               const u8 *addr, struct ieee80211_vif *vif),
 +      TP_PROTO(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata),
  
 -      TP_ARGS(local, addr, vif),
 +      TP_ARGS(local, sdata),
  
        TP_STRUCT__entry(
                LOCAL_ENTRY
        TP_fast_assign(
                LOCAL_ASSIGN;
                VIF_ASSIGN;
 -              memcpy(__entry->addr, addr, 6);
 +              memcpy(__entry->addr, sdata->vif.addr, 6);
        ),
  
        TP_printk(
@@@ -140,7 -140,6 +140,7 @@@ TRACE_EVENT(drv_config
                __field(u8, short_frame_max_tx_count)
                __field(int, center_freq)
                __field(int, channel_type)
 +              __field(int, smps)
        ),
  
        TP_fast_assign(
                __entry->short_frame_max_tx_count = local->hw.conf.short_frame_max_tx_count;
                __entry->center_freq = local->hw.conf.channel->center_freq;
                __entry->channel_type = local->hw.conf.channel_type;
 +              __entry->smps = local->hw.conf.smps_mode;
        ),
  
        TP_printk(
  
  TRACE_EVENT(drv_bss_info_changed,
        TP_PROTO(struct ieee80211_local *local,
 -               struct ieee80211_vif *vif,
 +               struct ieee80211_sub_if_data *sdata,
                 struct ieee80211_bss_conf *info,
                 u32 changed),
  
 -      TP_ARGS(local, vif, info, changed),
 +      TP_ARGS(local, sdata, info, changed),
  
        TP_STRUCT__entry(
                LOCAL_ENTRY
@@@ -295,11 -293,11 +295,11 @@@ TRACE_EVENT(drv_set_tim
  
  TRACE_EVENT(drv_set_key,
        TP_PROTO(struct ieee80211_local *local,
 -               enum set_key_cmd cmd, struct ieee80211_vif *vif,
 +               enum set_key_cmd cmd, struct ieee80211_sub_if_data *sdata,
                 struct ieee80211_sta *sta,
                 struct ieee80211_key_conf *key, int ret),
  
 -      TP_ARGS(local, cmd, vif, sta, key, ret),
 +      TP_ARGS(local, cmd, sdata, sta, key, ret),
  
        TP_STRUCT__entry(
                LOCAL_ENTRY
@@@ -491,36 -489,13 +491,36 @@@ TRACE_EVENT(drv_set_rts_threshold
        )
  );
  
 +TRACE_EVENT(drv_set_coverage_class,
 +      TP_PROTO(struct ieee80211_local *local, u8 value, int ret),
 +
 +      TP_ARGS(local, value, ret),
 +
 +      TP_STRUCT__entry(
 +              LOCAL_ENTRY
 +              __field(u8, value)
 +              __field(int, ret)
 +      ),
 +
 +      TP_fast_assign(
 +              LOCAL_ASSIGN;
 +              __entry->ret = ret;
 +              __entry->value = value;
 +      ),
 +
 +      TP_printk(
 +              LOCAL_PR_FMT " value:%d ret:%d",
 +              LOCAL_PR_ARG, __entry->value, __entry->ret
 +      )
 +);
 +
  TRACE_EVENT(drv_sta_notify,
        TP_PROTO(struct ieee80211_local *local,
 -               struct ieee80211_vif *vif,
 +               struct ieee80211_sub_if_data *sdata,
                 enum sta_notify_cmd cmd,
                 struct ieee80211_sta *sta),
  
 -      TP_ARGS(local, vif, cmd, sta),
 +      TP_ARGS(local, sdata, cmd, sta),
  
        TP_STRUCT__entry(
                LOCAL_ENTRY
@@@ -681,12 -656,12 +681,12 @@@ TRACE_EVENT(drv_tx_last_beacon
  
  TRACE_EVENT(drv_ampdu_action,
        TP_PROTO(struct ieee80211_local *local,
 -               struct ieee80211_vif *vif,
 +               struct ieee80211_sub_if_data *sdata,
                 enum ieee80211_ampdu_mlme_action action,
                 struct ieee80211_sta *sta, u16 tid,
                 u16 *ssn, int ret),
  
 -      TP_ARGS(local, vif, action, sta, tid, ssn, ret),
 +      TP_ARGS(local, sdata, action, sta, tid, ssn, ret),
  
        TP_STRUCT__entry(
                LOCAL_ENTRY
                __entry->ret = ret;
                __entry->action = action;
                __entry->tid = tid;
-               __entry->ssn = *ssn;
+               __entry->ssn = ssn ? *ssn : 0;
        ),
  
        TP_printk(
                LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->action, __entry->tid, __entry->ret
        )
  );
 +
 +TRACE_EVENT(drv_flush,
 +      TP_PROTO(struct ieee80211_local *local, bool drop),
 +
 +      TP_ARGS(local, drop),
 +
 +      TP_STRUCT__entry(
 +              LOCAL_ENTRY
 +              __field(bool, drop)
 +      ),
 +
 +      TP_fast_assign(
 +              LOCAL_ASSIGN;
 +              __entry->drop = drop;
 +      ),
 +
 +      TP_printk(
 +              LOCAL_PR_FMT " drop:%d",
 +              LOCAL_PR_ARG, __entry->drop
 +      )
 +);
  #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
  
  #undef TRACE_INCLUDE_PATH