iwlagn: free the Tx cmd when a non empty Tx queue is freed
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / iwl-agn.c
index cb8a9f9a22df7077ec91cc6a868b80d86ca2d637..1142d85ea8817c483fb43910e985834fbb6ecb13 100644 (file)
@@ -135,7 +135,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
         * beacon contents.
         */
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (!priv->beacon_ctx) {
                IWL_ERR(priv, "trying to build beacon w/o beacon context!\n");
@@ -180,7 +180,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
                rate = info->control.rates[0].idx;
 
        priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
-                                             priv->hw_params.valid_tx_ant);
+                                             hw_params(priv).valid_tx_ant);
        rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
 
        /* In mac80211, rates for 5 GHz start at 0 */
@@ -200,7 +200,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
        cmd.data[1] = priv->beacon_skb->data;
        cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY;
 
-       return trans_send_cmd(&priv->trans, &cmd);
+       return iwl_trans_send_cmd(trans(priv), &cmd);
 }
 
 static void iwl_bg_beacon_update(struct work_struct *work)
@@ -209,7 +209,7 @@ static void iwl_bg_beacon_update(struct work_struct *work)
                container_of(work, struct iwl_priv, beacon_update);
        struct sk_buff *beacon;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        if (!priv->beacon_ctx) {
                IWL_ERR(priv, "updating beacon w/o beacon context!\n");
                goto out;
@@ -239,7 +239,7 @@ static void iwl_bg_beacon_update(struct work_struct *work)
 
        iwlagn_send_beacon_cmd(priv);
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 static void iwl_bg_bt_runtime_config(struct work_struct *work)
@@ -247,11 +247,11 @@ static void iwl_bg_bt_runtime_config(struct work_struct *work)
        struct iwl_priv *priv =
                container_of(work, struct iwl_priv, bt_runtime_config);
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        /* dont send host command if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return;
        iwlagn_send_advance_bt_config(priv);
 }
@@ -262,13 +262,13 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work)
                container_of(work, struct iwl_priv, bt_full_concurrency);
        struct iwl_rxon_context *ctx;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                goto out;
 
        /* dont send host command if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                goto out;
 
        IWL_DEBUG_INFO(priv, "BT coex in %s mode\n",
@@ -286,7 +286,7 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work)
 
        iwlagn_send_advance_bt_config(priv);
 out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 /**
@@ -303,11 +303,11 @@ static void iwl_bg_statistics_periodic(unsigned long data)
 {
        struct iwl_priv *priv = (struct iwl_priv *)data;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        /* dont send host command if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return;
 
        iwl_send_statistics_request(priv, CMD_ASYNC, false);
@@ -329,14 +329,14 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
                ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32));
 
        /* Make sure device is powered up for SRAM reads */
-       spin_lock_irqsave(&priv->reg_lock, reg_flags);
-       if (iwl_grab_nic_access(priv)) {
-               spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+       spin_lock_irqsave(&bus(priv)->reg_lock, reg_flags);
+       if (iwl_grab_nic_access(bus(priv))) {
+               spin_unlock_irqrestore(&bus(priv)->reg_lock, reg_flags);
                return;
        }
 
        /* Set starting address; reads will auto-increment */
-       iwl_write32(priv, HBUS_TARG_MEM_RADDR, ptr);
+       iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, ptr);
        rmb();
 
        /*
@@ -344,20 +344,20 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
         * place event id # at far right for easier visual parsing.
         */
        for (i = 0; i < num_events; i++) {
-               ev = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
-               time = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
+               ev = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
+               time = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
                if (mode == 0) {
                        trace_iwlwifi_dev_ucode_cont_event(priv,
                                                        0, time, ev);
                } else {
-                       data = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
+                       data = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
                        trace_iwlwifi_dev_ucode_cont_event(priv,
                                                time, data, ev);
                }
        }
        /* Allow device to power down */
-       iwl_release_nic_access(priv);
-       spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
+       iwl_release_nic_access(bus(priv));
+       spin_unlock_irqrestore(&bus(priv)->reg_lock, reg_flags);
 }
 
 static void iwl_continuous_event_trace(struct iwl_priv *priv)
@@ -370,10 +370,12 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv)
 
        base = priv->device_pointers.error_event_table;
        if (iwlagn_hw_valid_rtc_data_addr(base)) {
-               capacity = iwl_read_targ_mem(priv, base);
-               num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
-               mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32)));
-               next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32)));
+               capacity = iwl_read_targ_mem(bus(priv), base);
+               num_wraps = iwl_read_targ_mem(bus(priv),
+                                               base + (2 * sizeof(u32)));
+               mode = iwl_read_targ_mem(bus(priv), base + (1 * sizeof(u32)));
+               next_entry = iwl_read_targ_mem(bus(priv),
+                                               base + (3 * sizeof(u32)));
        } else
                return;
 
@@ -424,7 +426,7 @@ static void iwl_bg_ucode_trace(unsigned long data)
 {
        struct iwl_priv *priv = (struct iwl_priv *)data;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        if (priv->event_log.ucode_trace) {
@@ -440,11 +442,11 @@ static void iwl_bg_tx_flush(struct work_struct *work)
        struct iwl_priv *priv =
                container_of(work, struct iwl_priv, tx_flush);
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
        /* do nothing if rf-kill is on */
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return;
 
        IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n");
@@ -473,14 +475,15 @@ static void iwl_bg_tx_flush(struct work_struct *work)
 static ssize_t show_debug_level(struct device *d,
                                struct device_attribute *attr, char *buf)
 {
-       struct iwl_priv *priv = dev_get_drvdata(d);
-       return sprintf(buf, "0x%08X\n", iwl_get_debug_level(priv));
+       struct iwl_shared *shrd = dev_get_drvdata(d);
+       return sprintf(buf, "0x%08X\n", iwl_get_debug_level(shrd));
 }
 static ssize_t store_debug_level(struct device *d,
                                struct device_attribute *attr,
                                 const char *buf, size_t count)
 {
-       struct iwl_priv *priv = dev_get_drvdata(d);
+       struct iwl_shared *shrd = dev_get_drvdata(d);
+       struct iwl_priv *priv = shrd->priv;
        unsigned long val;
        int ret;
 
@@ -488,9 +491,9 @@ static ssize_t store_debug_level(struct device *d,
        if (ret)
                IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf);
        else {
-               priv->debug_level = val;
+               shrd->dbg_level_dev = val;
                if (iwl_alloc_traffic_mem(priv))
-                       IWL_ERR(priv,
+                       IWL_ERR(shrd->priv,
                                "Not enough memory to generate traffic log\n");
        }
        return strnlen(buf, count);
@@ -506,9 +509,10 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
 static ssize_t show_temperature(struct device *d,
                                struct device_attribute *attr, char *buf)
 {
-       struct iwl_priv *priv = dev_get_drvdata(d);
+       struct iwl_shared *shrd = dev_get_drvdata(d);
+       struct iwl_priv *priv = shrd->priv;
 
-       if (!iwl_is_alive(priv))
+       if (!iwl_is_alive(priv->shrd))
                return -EAGAIN;
 
        return sprintf(buf, "%d\n", priv->temperature);
@@ -521,7 +525,7 @@ static ssize_t show_tx_power(struct device *d,
 {
        struct iwl_priv *priv = dev_get_drvdata(d);
 
-       if (!iwl_is_ready_rf(priv))
+       if (!iwl_is_ready_rf(priv->shrd))
                return sprintf(buf, "off\n");
        else
                return sprintf(buf, "%d\n", priv->tx_power_user_lmt);
@@ -613,33 +617,15 @@ static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc,
 
 static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags)
 {
-       static const u8 iwlagn_bss_ac_to_fifo[] = {
-               IWL_TX_FIFO_VO,
-               IWL_TX_FIFO_VI,
-               IWL_TX_FIFO_BE,
-               IWL_TX_FIFO_BK,
-       };
-       static const u8 iwlagn_bss_ac_to_queue[] = {
-               0, 1, 2, 3,
-       };
-       static const u8 iwlagn_pan_ac_to_fifo[] = {
-               IWL_TX_FIFO_VO_IPAN,
-               IWL_TX_FIFO_VI_IPAN,
-               IWL_TX_FIFO_BE_IPAN,
-               IWL_TX_FIFO_BK_IPAN,
-       };
-       static const u8 iwlagn_pan_ac_to_queue[] = {
-               7, 6, 5, 4,
-       };
        int i;
 
        /*
         * The default context is always valid,
         * the PAN context depends on uCode.
         */
-       priv->valid_contexts = BIT(IWL_RXON_CTX_BSS);
+       priv->shrd->valid_contexts = BIT(IWL_RXON_CTX_BSS);
        if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN)
-               priv->valid_contexts |= BIT(IWL_RXON_CTX_PAN);
+               priv->shrd->valid_contexts |= BIT(IWL_RXON_CTX_PAN);
 
        for (i = 0; i < NUM_IWL_RXON_CTX; i++)
                priv->contexts[i].ctxid = i;
@@ -652,8 +638,6 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags)
        priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
        priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID;
        priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
-       priv->contexts[IWL_RXON_CTX_BSS].ac_to_fifo = iwlagn_bss_ac_to_fifo;
-       priv->contexts[IWL_RXON_CTX_BSS].ac_to_queue = iwlagn_bss_ac_to_queue;
        priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes =
                BIT(NL80211_IFTYPE_ADHOC);
        priv->contexts[IWL_RXON_CTX_BSS].interface_modes =
@@ -673,9 +657,6 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags)
        priv->contexts[IWL_RXON_CTX_PAN].wep_key_cmd = REPLY_WIPAN_WEPKEY;
        priv->contexts[IWL_RXON_CTX_PAN].bcast_sta_id = IWLAGN_PAN_BCAST_ID;
        priv->contexts[IWL_RXON_CTX_PAN].station_flags = STA_FLG_PAN_STATION;
-       priv->contexts[IWL_RXON_CTX_PAN].ac_to_fifo = iwlagn_pan_ac_to_fifo;
-       priv->contexts[IWL_RXON_CTX_PAN].ac_to_queue = iwlagn_pan_ac_to_queue;
-       priv->contexts[IWL_RXON_CTX_PAN].mcast_queue = IWL_IPAN_MCAST_QUEUE;
        priv->contexts[IWL_RXON_CTX_PAN].interface_modes =
                BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP);
 
@@ -1147,25 +1128,25 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
                       pieces.init_data_size);
 
        /* Verify that uCode images will fit in card's SRAM */
-       if (pieces.inst_size > priv->hw_params.max_inst_size) {
+       if (pieces.inst_size > hw_params(priv).max_inst_size) {
                IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n",
                        pieces.inst_size);
                goto try_again;
        }
 
-       if (pieces.data_size > priv->hw_params.max_data_size) {
+       if (pieces.data_size > hw_params(priv).max_data_size) {
                IWL_ERR(priv, "uCode data len %Zd too large to fit in\n",
                        pieces.data_size);
                goto try_again;
        }
 
-       if (pieces.init_size > priv->hw_params.max_inst_size) {
+       if (pieces.init_size > hw_params(priv).max_inst_size) {
                IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n",
                        pieces.init_size);
                goto try_again;
        }
 
-       if (pieces.init_data_size > priv->hw_params.max_data_size) {
+       if (pieces.init_data_size > hw_params(priv).max_data_size) {
                IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n",
                        pieces.init_data_size);
                goto try_again;
@@ -1242,10 +1223,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
 
        if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) {
                priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN;
-               priv->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM;
+               priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM;
        } else {
                priv->sta_key_max_num = STA_KEY_MAX_NUM;
-               priv->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;
+               priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;
        }
 
        /*
@@ -1306,364 +1287,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
        release_firmware(ucode_raw);
 }
 
-static const char * const desc_lookup_text[] = {
-       "OK",
-       "FAIL",
-       "BAD_PARAM",
-       "BAD_CHECKSUM",
-       "NMI_INTERRUPT_WDG",
-       "SYSASSERT",
-       "FATAL_ERROR",
-       "BAD_COMMAND",
-       "HW_ERROR_TUNE_LOCK",
-       "HW_ERROR_TEMPERATURE",
-       "ILLEGAL_CHAN_FREQ",
-       "VCC_NOT_STABLE",
-       "FH_ERROR",
-       "NMI_INTERRUPT_HOST",
-       "NMI_INTERRUPT_ACTION_PT",
-       "NMI_INTERRUPT_UNKNOWN",
-       "UCODE_VERSION_MISMATCH",
-       "HW_ERROR_ABS_LOCK",
-       "HW_ERROR_CAL_LOCK_FAIL",
-       "NMI_INTERRUPT_INST_ACTION_PT",
-       "NMI_INTERRUPT_DATA_ACTION_PT",
-       "NMI_TRM_HW_ER",
-       "NMI_INTERRUPT_TRM",
-       "NMI_INTERRUPT_BREAK_POINT",
-       "DEBUG_0",
-       "DEBUG_1",
-       "DEBUG_2",
-       "DEBUG_3",
-};
-
-static struct { char *name; u8 num; } advanced_lookup[] = {
-       { "NMI_INTERRUPT_WDG", 0x34 },
-       { "SYSASSERT", 0x35 },
-       { "UCODE_VERSION_MISMATCH", 0x37 },
-       { "BAD_COMMAND", 0x38 },
-       { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C },
-       { "FATAL_ERROR", 0x3D },
-       { "NMI_TRM_HW_ERR", 0x46 },
-       { "NMI_INTERRUPT_TRM", 0x4C },
-       { "NMI_INTERRUPT_BREAK_POINT", 0x54 },
-       { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C },
-       { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 },
-       { "NMI_INTERRUPT_HOST", 0x66 },
-       { "NMI_INTERRUPT_ACTION_PT", 0x7C },
-       { "NMI_INTERRUPT_UNKNOWN", 0x84 },
-       { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 },
-       { "ADVANCED_SYSASSERT", 0 },
-};
-
-static const char *desc_lookup(u32 num)
-{
-       int i;
-       int max = ARRAY_SIZE(desc_lookup_text);
-
-       if (num < max)
-               return desc_lookup_text[num];
-
-       max = ARRAY_SIZE(advanced_lookup) - 1;
-       for (i = 0; i < max; i++) {
-               if (advanced_lookup[i].num == num)
-                       break;
-       }
-       return advanced_lookup[i].name;
-}
-
-#define ERROR_START_OFFSET  (1 * sizeof(u32))
-#define ERROR_ELEM_SIZE     (7 * sizeof(u32))
-
-void iwl_dump_nic_error_log(struct iwl_priv *priv)
-{
-       u32 base;
-       struct iwl_error_event_table table;
-
-       base = priv->device_pointers.error_event_table;
-       if (priv->ucode_type == IWL_UCODE_INIT) {
-               if (!base)
-                       base = priv->init_errlog_ptr;
-       } else {
-               if (!base)
-                       base = priv->inst_errlog_ptr;
-       }
-
-       if (!iwlagn_hw_valid_rtc_data_addr(base)) {
-               IWL_ERR(priv,
-                       "Not valid error log pointer 0x%08X for %s uCode\n",
-                       base,
-                       (priv->ucode_type == IWL_UCODE_INIT)
-                                       ? "Init" : "RT");
-               return;
-       }
-
-       iwl_read_targ_mem_words(priv, base, &table, sizeof(table));
-
-       if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
-               IWL_ERR(priv, "Start IWL Error Log Dump:\n");
-               IWL_ERR(priv, "Status: 0x%08lX, count: %d\n",
-                       priv->status, table.valid);
-       }
-
-       priv->isr_stats.err_code = table.error_id;
-
-       trace_iwlwifi_dev_ucode_error(priv, table.error_id, table.tsf_low,
-                                     table.data1, table.data2, table.line,
-                                     table.blink1, table.blink2, table.ilink1,
-                                     table.ilink2, table.bcon_time, table.gp1,
-                                     table.gp2, table.gp3, table.ucode_ver,
-                                     table.hw_ver, table.brd_ver);
-       IWL_ERR(priv, "0x%08X | %-28s\n", table.error_id,
-               desc_lookup(table.error_id));
-       IWL_ERR(priv, "0x%08X | uPc\n", table.pc);
-       IWL_ERR(priv, "0x%08X | branchlink1\n", table.blink1);
-       IWL_ERR(priv, "0x%08X | branchlink2\n", table.blink2);
-       IWL_ERR(priv, "0x%08X | interruptlink1\n", table.ilink1);
-       IWL_ERR(priv, "0x%08X | interruptlink2\n", table.ilink2);
-       IWL_ERR(priv, "0x%08X | data1\n", table.data1);
-       IWL_ERR(priv, "0x%08X | data2\n", table.data2);
-       IWL_ERR(priv, "0x%08X | line\n", table.line);
-       IWL_ERR(priv, "0x%08X | beacon time\n", table.bcon_time);
-       IWL_ERR(priv, "0x%08X | tsf low\n", table.tsf_low);
-       IWL_ERR(priv, "0x%08X | tsf hi\n", table.tsf_hi);
-       IWL_ERR(priv, "0x%08X | time gp1\n", table.gp1);
-       IWL_ERR(priv, "0x%08X | time gp2\n", table.gp2);
-       IWL_ERR(priv, "0x%08X | time gp3\n", table.gp3);
-       IWL_ERR(priv, "0x%08X | uCode version\n", table.ucode_ver);
-       IWL_ERR(priv, "0x%08X | hw version\n", table.hw_ver);
-       IWL_ERR(priv, "0x%08X | board version\n", table.brd_ver);
-       IWL_ERR(priv, "0x%08X | hcmd\n", table.hcmd);
-}
-
-#define EVENT_START_OFFSET  (4 * sizeof(u32))
-
-/**
- * iwl_print_event_log - Dump error event log to syslog
- *
- */
-static int iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
-                              u32 num_events, u32 mode,
-                              int pos, char **buf, size_t bufsz)
-{
-       u32 i;
-       u32 base;       /* SRAM byte address of event log header */
-       u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */
-       u32 ptr;        /* SRAM byte address of log data */
-       u32 ev, time, data; /* event log data */
-       unsigned long reg_flags;
-
-       if (num_events == 0)
-               return pos;
-
-       base = priv->device_pointers.log_event_table;
-       if (priv->ucode_type == IWL_UCODE_INIT) {
-               if (!base)
-                       base = priv->init_evtlog_ptr;
-       } else {
-               if (!base)
-                       base = priv->inst_evtlog_ptr;
-       }
-
-       if (mode == 0)
-               event_size = 2 * sizeof(u32);
-       else
-               event_size = 3 * sizeof(u32);
-
-       ptr = base + EVENT_START_OFFSET + (start_idx * event_size);
-
-       /* Make sure device is powered up for SRAM reads */
-       spin_lock_irqsave(&priv->reg_lock, reg_flags);
-       iwl_grab_nic_access(priv);
-
-       /* Set starting address; reads will auto-increment */
-       iwl_write32(priv, HBUS_TARG_MEM_RADDR, ptr);
-       rmb();
-
-       /* "time" is actually "data" for mode 0 (no timestamp).
-       * place event id # at far right for easier visual parsing. */
-       for (i = 0; i < num_events; i++) {
-               ev = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
-               time = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
-               if (mode == 0) {
-                       /* data, ev */
-                       if (bufsz) {
-                               pos += scnprintf(*buf + pos, bufsz - pos,
-                                               "EVT_LOG:0x%08x:%04u\n",
-                                               time, ev);
-                       } else {
-                               trace_iwlwifi_dev_ucode_event(priv, 0,
-                                       time, ev);
-                               IWL_ERR(priv, "EVT_LOG:0x%08x:%04u\n",
-                                       time, ev);
-                       }
-               } else {
-                       data = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
-                       if (bufsz) {
-                               pos += scnprintf(*buf + pos, bufsz - pos,
-                                               "EVT_LOGT:%010u:0x%08x:%04u\n",
-                                                time, data, ev);
-                       } else {
-                               IWL_ERR(priv, "EVT_LOGT:%010u:0x%08x:%04u\n",
-                                       time, data, ev);
-                               trace_iwlwifi_dev_ucode_event(priv, time,
-                                       data, ev);
-                       }
-               }
-       }
-
-       /* Allow device to power down */
-       iwl_release_nic_access(priv);
-       spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
-       return pos;
-}
-
-/**
- * iwl_print_last_event_logs - Dump the newest # of event log to syslog
- */
-static int iwl_print_last_event_logs(struct iwl_priv *priv, u32 capacity,
-                                   u32 num_wraps, u32 next_entry,
-                                   u32 size, u32 mode,
-                                   int pos, char **buf, size_t bufsz)
-{
-       /*
-        * display the newest DEFAULT_LOG_ENTRIES entries
-        * i.e the entries just before the next ont that uCode would fill.
-        */
-       if (num_wraps) {
-               if (next_entry < size) {
-                       pos = iwl_print_event_log(priv,
-                                               capacity - (size - next_entry),
-                                               size - next_entry, mode,
-                                               pos, buf, bufsz);
-                       pos = iwl_print_event_log(priv, 0,
-                                                 next_entry, mode,
-                                                 pos, buf, bufsz);
-               } else
-                       pos = iwl_print_event_log(priv, next_entry - size,
-                                                 size, mode, pos, buf, bufsz);
-       } else {
-               if (next_entry < size) {
-                       pos = iwl_print_event_log(priv, 0, next_entry,
-                                                 mode, pos, buf, bufsz);
-               } else {
-                       pos = iwl_print_event_log(priv, next_entry - size,
-                                                 size, mode, pos, buf, bufsz);
-               }
-       }
-       return pos;
-}
-
-#define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20)
-
-int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
-                           char **buf, bool display)
-{
-       u32 base;       /* SRAM byte address of event log header */
-       u32 capacity;   /* event log capacity in # entries */
-       u32 mode;       /* 0 - no timestamp, 1 - timestamp recorded */
-       u32 num_wraps;  /* # times uCode wrapped to top of log */
-       u32 next_entry; /* index of next entry to be written by uCode */
-       u32 size;       /* # entries that we'll print */
-       u32 logsize;
-       int pos = 0;
-       size_t bufsz = 0;
-
-       base = priv->device_pointers.log_event_table;
-       if (priv->ucode_type == IWL_UCODE_INIT) {
-               logsize = priv->init_evtlog_size;
-               if (!base)
-                       base = priv->init_evtlog_ptr;
-       } else {
-               logsize = priv->inst_evtlog_size;
-               if (!base)
-                       base = priv->inst_evtlog_ptr;
-       }
-
-       if (!iwlagn_hw_valid_rtc_data_addr(base)) {
-               IWL_ERR(priv,
-                       "Invalid event log pointer 0x%08X for %s uCode\n",
-                       base,
-                       (priv->ucode_type == IWL_UCODE_INIT)
-                                       ? "Init" : "RT");
-               return -EINVAL;
-       }
-
-       /* event log header */
-       capacity = iwl_read_targ_mem(priv, base);
-       mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32)));
-       num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
-       next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32)));
-
-       if (capacity > logsize) {
-               IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n",
-                       capacity, logsize);
-               capacity = logsize;
-       }
-
-       if (next_entry > logsize) {
-               IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n",
-                       next_entry, logsize);
-               next_entry = logsize;
-       }
-
-       size = num_wraps ? capacity : next_entry;
-
-       /* bail out if nothing in log */
-       if (size == 0) {
-               IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n");
-               return pos;
-       }
-
-       /* enable/disable bt channel inhibition */
-       priv->bt_ch_announce = iwlagn_mod_params.bt_ch_announce;
-
-#ifdef CONFIG_IWLWIFI_DEBUG
-       if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
-               size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
-                       ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
-#else
-       size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
-               ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
-#endif
-       IWL_ERR(priv, "Start IWL Event Log Dump: display last %u entries\n",
-               size);
-
-#ifdef CONFIG_IWLWIFI_DEBUG
-       if (display) {
-               if (full_log)
-                       bufsz = capacity * 48;
-               else
-                       bufsz = size * 48;
-               *buf = kmalloc(bufsz, GFP_KERNEL);
-               if (!*buf)
-                       return -ENOMEM;
-       }
-       if ((iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) || full_log) {
-               /*
-                * if uCode has wrapped back to top of log,
-                * start at the oldest entry,
-                * i.e the next one that uCode would fill.
-                */
-               if (num_wraps)
-                       pos = iwl_print_event_log(priv, next_entry,
-                                               capacity - next_entry, mode,
-                                               pos, buf, bufsz);
-               /* (then/else) start at top of log */
-               pos = iwl_print_event_log(priv, 0,
-                                         next_entry, mode, pos, buf, bufsz);
-       } else
-               pos = iwl_print_last_event_logs(priv, capacity, num_wraps,
-                                               next_entry, size, mode,
-                                               pos, buf, bufsz);
-#else
-       pos = iwl_print_last_event_logs(priv, capacity, num_wraps,
-                                       next_entry, size, mode,
-                                       pos, buf, bufsz);
-#endif
-       return pos;
-}
-
 static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
 {
        struct iwl_ct_kill_config cmd;
@@ -1671,44 +1294,43 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
        unsigned long flags;
        int ret = 0;
 
-       spin_lock_irqsave(&priv->lock, flags);
-       iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
+       spin_lock_irqsave(&priv->shrd->lock, flags);
+       iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR,
                    CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->shrd->lock, flags);
        priv->thermal_throttle.ct_kill_toggle = false;
 
        if (priv->cfg->base_params->support_ct_kill_exit) {
                adv_cmd.critical_temperature_enter =
-                       cpu_to_le32(priv->hw_params.ct_kill_threshold);
+                       cpu_to_le32(hw_params(priv).ct_kill_threshold);
                adv_cmd.critical_temperature_exit =
-                       cpu_to_le32(priv->hw_params.ct_kill_exit_threshold);
+                       cpu_to_le32(hw_params(priv).ct_kill_exit_threshold);
 
-               ret = trans_send_cmd_pdu(&priv->trans,
+               ret = iwl_trans_send_cmd_pdu(trans(priv),
                                       REPLY_CT_KILL_CONFIG_CMD,
                                       CMD_SYNC, sizeof(adv_cmd), &adv_cmd);
                if (ret)
                        IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
                else
                        IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD "
-                                       "succeeded, "
-                                       "critical temperature enter is %d,"
-                                       "exit is %d\n",
-                                      priv->hw_params.ct_kill_threshold,
-                                      priv->hw_params.ct_kill_exit_threshold);
+                               "succeeded, critical temperature enter is %d,"
+                               "exit is %d\n",
+                               hw_params(priv).ct_kill_threshold,
+                               hw_params(priv).ct_kill_exit_threshold);
        } else {
                cmd.critical_temperature_R =
-                       cpu_to_le32(priv->hw_params.ct_kill_threshold);
+                       cpu_to_le32(hw_params(priv).ct_kill_threshold);
 
-               ret = trans_send_cmd_pdu(&priv->trans,
+               ret = iwl_trans_send_cmd_pdu(trans(priv),
                                       REPLY_CT_KILL_CONFIG_CMD,
                                       CMD_SYNC, sizeof(cmd), &cmd);
                if (ret)
                        IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
                else
                        IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD "
-                                       "succeeded, "
-                                       "critical temperature is %d\n",
-                                       priv->hw_params.ct_kill_threshold);
+                               "succeeded, "
+                               "critical temperature is %d\n",
+                               hw_params(priv).ct_kill_threshold);
        }
 }
 
@@ -1725,7 +1347,7 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg)
        calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
        calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg);
 
-       return trans_send_cmd(&priv->trans, &cmd);
+       return iwl_trans_send_cmd(trans(priv), &cmd);
 }
 
 
@@ -1737,7 +1359,7 @@ static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
 
        if (IWL_UCODE_API(priv->ucode_ver) > 1) {
                IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
-               return trans_send_cmd_pdu(&priv->trans,
+               return iwl_trans_send_cmd_pdu(trans(priv),
                                        TX_ANT_CONFIGURATION_CMD,
                                        CMD_SYNC,
                                        sizeof(struct iwl_tx_ant_config_cmd),
@@ -1759,17 +1381,17 @@ int iwl_alive_start(struct iwl_priv *priv)
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
        /*TODO: this should go to the transport layer */
-       iwl_reset_ict(priv);
+       iwl_reset_ict(trans(priv));
 
        IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
 
        /* After the ALIVE response, we can send host commands to the uCode */
-       set_bit(STATUS_ALIVE, &priv->status);
+       set_bit(STATUS_ALIVE, &priv->shrd->status);
 
        /* Enable watchdog to monitor the driver tx queues */
        iwl_setup_watchdog(priv);
 
-       if (iwl_is_rfkill(priv))
+       if (iwl_is_rfkill(priv->shrd))
                return -ERFKILL;
 
        /* download priority table before any calibration request */
@@ -1806,8 +1428,9 @@ int iwl_alive_start(struct iwl_priv *priv)
                iwl_send_bt_config(priv);
        }
 
-       if (priv->hw_params.calib_rt_cfg)
-               iwlagn_send_calib_cfg_rt(priv, priv->hw_params.calib_rt_cfg);
+       if (hw_params(priv).calib_rt_cfg)
+               iwlagn_send_calib_cfg_rt(priv,
+                                        hw_params(priv).calib_rt_cfg);
 
        ieee80211_wake_queues(priv->hw);
 
@@ -1816,7 +1439,7 @@ int iwl_alive_start(struct iwl_priv *priv)
        /* Configure Tx antenna selection based on H/W config */
        iwlagn_send_tx_ant_config(priv, priv->cfg->valid_tx_ant);
 
-       if (iwl_is_associated_ctx(ctx) && !priv->wowlan) {
+       if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) {
                struct iwl_rxon_cmd *active_rxon =
                                (struct iwl_rxon_cmd *)&ctx->active;
                /* apply any changes in staging */
@@ -1831,12 +1454,12 @@ int iwl_alive_start(struct iwl_priv *priv)
                iwlagn_set_rxon_chain(priv, ctx);
        }
 
-       if (!priv->wowlan) {
+       if (!priv->shrd->wowlan) {
                /* WoWLAN ucode will not reply in the same way, skip it */
                iwl_reset_run_time_calib(priv);
        }
 
-       set_bit(STATUS_READY, &priv->status);
+       set_bit(STATUS_READY, &priv->shrd->status);
 
        /* Configure the adapter for unassociated operation */
        ret = iwlagn_commit_rxon(priv, ctx);
@@ -1868,7 +1491,8 @@ static void __iwl_down(struct iwl_priv *priv)
         */
        ieee80211_remain_on_channel_expired(priv->hw);
 
-       exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status);
+       exit_pending =
+               test_and_set_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
 
        /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
         * to prevent rearm timer */
@@ -1893,32 +1517,33 @@ static void __iwl_down(struct iwl_priv *priv)
        /* Wipe out the EXIT_PENDING status bit if we are not actually
         * exiting the module */
        if (!exit_pending)
-               clear_bit(STATUS_EXIT_PENDING, &priv->status);
+               clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
 
-       if (priv->mac80211_registered)
+       if (priv->shrd->mac80211_registered)
                ieee80211_stop_queues(priv->hw);
 
+       iwl_trans_stop_device(trans(priv));
+
        /* Clear out all status bits but a few that are stable across reset */
-       priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) <<
+       priv->shrd->status &=
+                       test_bit(STATUS_RF_KILL_HW, &priv->shrd->status) <<
                                STATUS_RF_KILL_HW |
-                       test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
+                       test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status) <<
                                STATUS_GEO_CONFIGURED |
-                       test_bit(STATUS_FW_ERROR, &priv->status) <<
+                       test_bit(STATUS_FW_ERROR, &priv->shrd->status) <<
                                STATUS_FW_ERROR |
-                      test_bit(STATUS_EXIT_PENDING, &priv->status) <<
+                       test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) <<
                                STATUS_EXIT_PENDING;
 
-       trans_stop_device(&priv->trans);
-
        dev_kfree_skb(priv->beacon_skb);
        priv->beacon_skb = NULL;
 }
 
 static void iwl_down(struct iwl_priv *priv)
 {
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        __iwl_down(priv);
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        iwl_cancel_deferred_work(priv);
 }
@@ -1930,9 +1555,9 @@ static int __iwl_up(struct iwl_priv *priv)
        struct iwl_rxon_context *ctx;
        int ret;
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) {
                IWL_WARN(priv, "Exit pending; will not bring the NIC up\n");
                return -EIO;
        }
@@ -1965,9 +1590,9 @@ static int __iwl_up(struct iwl_priv *priv)
        return 0;
 
  error:
-       set_bit(STATUS_EXIT_PENDING, &priv->status);
+       set_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
        __iwl_down(priv);
-       clear_bit(STATUS_EXIT_PENDING, &priv->status);
+       clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
 
        IWL_ERR(priv, "Unable to initialize device.\n");
        return ret;
@@ -1985,11 +1610,11 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
        struct iwl_priv *priv = container_of(work, struct iwl_priv,
                        run_time_calib_work);
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
-           test_bit(STATUS_SCANNING, &priv->status)) {
-               mutex_unlock(&priv->mutex);
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) ||
+           test_bit(STATUS_SCANNING, &priv->shrd->status)) {
+               mutex_unlock(&priv->shrd->mutex);
                return;
        }
 
@@ -1998,7 +1623,7 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
                iwl_sensitivity_calibration(priv);
        }
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 static void iwlagn_prepare_restart(struct iwl_priv *priv)
@@ -2010,7 +1635,7 @@ static void iwlagn_prepare_restart(struct iwl_priv *priv)
        u8 bt_status;
        bool bt_is_sco;
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        for_each_context(priv, ctx)
                ctx->vif = NULL;
@@ -2044,13 +1669,13 @@ static void iwl_bg_restart(struct work_struct *data)
 {
        struct iwl_priv *priv = container_of(data, struct iwl_priv, restart);
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                return;
 
-       if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
-               mutex_lock(&priv->mutex);
+       if (test_and_clear_bit(STATUS_FW_ERROR, &priv->shrd->status)) {
+               mutex_lock(&priv->shrd->mutex);
                iwlagn_prepare_restart(priv);
-               mutex_unlock(&priv->mutex);
+               mutex_unlock(&priv->shrd->mutex);
                iwl_cancel_deferred_work(priv);
                ieee80211_restart_hw(priv->hw);
        } else {
@@ -2238,7 +1863,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
                IWL_ERR(priv, "Failed to register hw (error %d)\n", ret);
                return ret;
        }
-       priv->mac80211_registered = 1;
+       priv->shrd->mac80211_registered = 1;
 
        return 0;
 }
@@ -2252,16 +1877,16 @@ static int iwlagn_mac_start(struct ieee80211_hw *hw)
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
        /* we should be verifying the device is ready to be opened */
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        ret = __iwl_up(priv);
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        if (ret)
                return ret;
 
        IWL_DEBUG_INFO(priv, "Start UP work done.\n");
 
        /* Now we should be done, and the READY bit should be set. */
-       if (WARN_ON(!test_bit(STATUS_READY, &priv->status)))
+       if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status)))
                ret = -EIO;
 
        iwlagn_led_enable(priv);
@@ -2284,11 +1909,11 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw)
 
        iwl_down(priv);
 
-       flush_workqueue(priv->workqueue);
+       flush_workqueue(priv->shrd->workqueue);
 
        /* User space software may expect getting rfkill changes
         * even if interface is down */
-       iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
+       iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF);
        iwl_enable_rfkill_int(priv);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -2332,7 +1957,7 @@ static int iwlagn_send_patterns(struct iwl_priv *priv,
        }
 
        cmd.data[0] = pattern_cmd;
-       err = trans_send_cmd(&priv->trans, &cmd);
+       err = iwl_trans_send_cmd(trans(priv), &cmd);
        kfree(pattern_cmd);
        return err;
 }
@@ -2347,7 +1972,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
        if (iwlagn_mod_params.sw_crypto)
                return;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif)
                goto out;
@@ -2358,7 +1983,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
        priv->have_rekey_data = true;
 
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 struct wowlan_key_data {
@@ -2396,7 +2021,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
        u16 p1k[IWLAGN_P1K_SIZE];
        int ret, i;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
             key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
@@ -2501,7 +2126,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
                break;
        }
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
@@ -2526,7 +2151,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
        if (WARN_ON(!wowlan))
                return -EINVAL;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        /* Don't attempt WoWLAN when not associated, tear down instead. */
        if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION ||
@@ -2555,7 +2180,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
         * since the uCode will add 0x10 before using the value.
         */
        for (i = 0; i < 8; i++) {
-               seq = priv->stations[IWL_AP_ID].tid[i].seq_number;
+               seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number;
                seq -= 0x10;
                wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq);
        }
@@ -2587,9 +2212,9 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
 
        memcpy(&rxon, &ctx->active, sizeof(rxon));
 
-       trans_stop_device(&priv->trans);
+       iwl_trans_stop_device(trans(priv));
 
-       priv->wowlan = true;
+       priv->shrd->wowlan = true;
 
        ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_wowlan,
                                           IWL_UCODE_WOWLAN);
@@ -2620,11 +2245,11 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
                 * constraints. Since we're in the suspend path
                 * that isn't really a problem though.
                 */
-               mutex_unlock(&priv->mutex);
+               mutex_unlock(&priv->shrd->mutex);
                ieee80211_iter_keys(priv->hw, ctx->vif,
                                    iwlagn_wowlan_program_keys,
                                    &key_data);
-               mutex_lock(&priv->mutex);
+               mutex_lock(&priv->shrd->mutex);
                if (key_data.error) {
                        ret = -EIO;
                        goto error;
@@ -2639,13 +2264,13 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
                                .len[0] = sizeof(*key_data.rsc_tsc),
                        };
 
-                       ret = trans_send_cmd(&priv->trans, &rsc_tsc_cmd);
+                       ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd);
                        if (ret)
                                goto error;
                }
 
                if (key_data.use_tkip) {
-                       ret = trans_send_cmd_pdu(&priv->trans,
+                       ret = iwl_trans_send_cmd_pdu(trans(priv),
                                                 REPLY_WOWLAN_TKIP_PARAMS,
                                                 CMD_SYNC, sizeof(tkip_cmd),
                                                 &tkip_cmd);
@@ -2661,7 +2286,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
                        kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
                        kek_kck_cmd.replay_ctr = priv->replay_ctr;
 
-                       ret = trans_send_cmd_pdu(&priv->trans,
+                       ret = iwl_trans_send_cmd_pdu(trans(priv),
                                                 REPLY_WOWLAN_KEK_KCK_MATERIAL,
                                                 CMD_SYNC, sizeof(kek_kck_cmd),
                                                 &kek_kck_cmd);
@@ -2670,7 +2295,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
                }
        }
 
-       ret = trans_send_cmd_pdu(&priv->trans, REPLY_WOWLAN_WAKEUP_FILTER,
+       ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER,
                                 CMD_SYNC, sizeof(wakeup_filter_cmd),
                                 &wakeup_filter_cmd);
        if (ret)
@@ -2683,17 +2308,17 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
        device_set_wakeup_enable(priv->bus->dev, true);
 
        /* Now let the ucode operate on its own */
-       iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
+       iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET,
                          CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
 
        goto out;
 
  error:
-       priv->wowlan = false;
+       priv->shrd->wowlan = false;
        iwlagn_prepare_restart(priv);
        ieee80211_restart_hw(priv->hw);
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        kfree(key_data.rsc_tsc);
        return ret;
 }
@@ -2707,21 +2332,21 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        u32 base, status = 0xffffffff;
        int ret = -EIO;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
-       iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
+       iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR,
                          CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
 
        base = priv->device_pointers.error_event_table;
        if (iwlagn_hw_valid_rtc_data_addr(base)) {
-               spin_lock_irqsave(&priv->reg_lock, flags);
-               ret = iwl_grab_nic_access_silent(priv);
+               spin_lock_irqsave(&bus(priv)->reg_lock, flags);
+               ret = iwl_grab_nic_access_silent(bus(priv));
                if (ret == 0) {
-                       iwl_write32(priv, HBUS_TARG_MEM_RADDR, base);
-                       status = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
-                       iwl_release_nic_access(priv);
+                       iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base);
+                       status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
+                       iwl_release_nic_access(bus(priv));
                }
-               spin_unlock_irqrestore(&priv->reg_lock, flags);
+               spin_unlock_irqrestore(&bus(priv)->reg_lock, flags);
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
                if (ret == 0) {
@@ -2732,7 +2357,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
 
                        if (priv->wowlan_sram)
                                _iwl_read_targ_mem_words(
-                                       priv, 0x800000, priv->wowlan_sram,
+                                       bus(priv), 0x800000, priv->wowlan_sram,
                                        priv->ucode_wowlan.data.len / 4);
                }
 #endif
@@ -2741,7 +2366,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        /* we'll clear ctx->vif during iwlagn_prepare_restart() */
        vif = ctx->vif;
 
-       priv->wowlan = false;
+       priv->shrd->wowlan = false;
 
        device_set_wakeup_enable(priv->bus->dev, false);
 
@@ -2751,7 +2376,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        iwl_connection_init_rx_config(priv, ctx);
        iwlagn_set_rxon_chain(priv, ctx);
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        ieee80211_resume_disconnect(vif);
 
@@ -2820,7 +2445,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET)
                return 0;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        iwl_scan_cancel_timeout(priv, 100);
 
        BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT);
@@ -2871,7 +2496,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                ret = -EINVAL;
        }
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return ret;
@@ -2886,6 +2511,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
        struct iwl_priv *priv = hw->priv;
        int ret = -EINVAL;
        struct iwl_station_priv *sta_priv = (void *) sta->drv_priv;
+       struct iwl_rxon_context *ctx =  iwl_rxon_ctx_from_vif(vif);
 
        IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n",
                     sta->addr, tid);
@@ -2893,7 +2519,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
        if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE))
                return -EACCES;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        switch (action) {
        case IEEE80211_AMPDU_RX_START:
@@ -2903,7 +2529,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
        case IEEE80211_AMPDU_RX_STOP:
                IWL_DEBUG_HT(priv, "stop Rx\n");
                ret = iwl_sta_rx_agg_stop(priv, sta, tid);
-               if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+               if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                        ret = 0;
                break;
        case IEEE80211_AMPDU_TX_START:
@@ -2923,7 +2549,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
                        IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
                                     priv->agg_tids_count);
                }
-               if (test_bit(STATUS_EXIT_PENDING, &priv->status))
+               if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                        ret = 0;
                if (priv->cfg->ht_params &&
                    priv->cfg->ht_params->use_rts_for_aggregation) {
@@ -2939,8 +2565,8 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
        case IEEE80211_AMPDU_TX_OPERATIONAL:
                buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF);
 
-               trans_txq_agg_setup(&priv->trans, iwl_sta_id(sta), tid,
-                               buf_size);
+               iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta),
+                               tid, buf_size);
 
                /*
                 * If the limit is 0, then it wasn't initialised yet,
@@ -2984,7 +2610,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
                ret = 0;
                break;
        }
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        return ret;
 }
@@ -3002,7 +2628,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
 
        IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
                        sta->addr);
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n",
                        sta->addr);
        sta_priv->common.sta_id = IWL_INVALID_STATION;
@@ -3017,7 +2643,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
                IWL_ERR(priv, "Unable to add station %pM (%d)\n",
                        sta->addr, ret);
                /* Should we return success if return code is EEXIST ? */
-               mutex_unlock(&priv->mutex);
+               mutex_unlock(&priv->shrd->mutex);
                return ret;
        }
 
@@ -3027,7 +2653,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
        IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
                       sta->addr);
        iwl_rs_rate_init(priv, sta, sta_id);
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        return 0;
 }
@@ -3053,14 +2679,14 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
-       if (iwl_is_rfkill(priv))
+       if (iwl_is_rfkill(priv->shrd))
                goto out;
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
-           test_bit(STATUS_SCANNING, &priv->status) ||
-           test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) ||
+           test_bit(STATUS_SCANNING, &priv->shrd->status) ||
+           test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status))
                goto out;
 
        if (!iwl_is_associated_ctx(ctx))
@@ -3079,7 +2705,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
                goto out;
        }
 
-       spin_lock_irq(&priv->lock);
+       spin_lock_irq(&priv->shrd->lock);
 
        priv->current_ht_config.smps = conf->smps_mode;
 
@@ -3109,23 +2735,23 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
        iwl_set_rxon_ht(priv, ht_conf);
        iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif);
 
-       spin_unlock_irq(&priv->lock);
+       spin_unlock_irq(&priv->shrd->lock);
 
        iwl_set_rate(priv);
        /*
         * at this point, staging_rxon has the
         * configuration for channel switch
         */
-       set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
+       set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status);
        priv->switch_channel = cpu_to_le16(ch);
        if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) {
-               clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
+               clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status);
                priv->switch_channel = 0;
                ieee80211_chswitch_done(ctx->vif, false);
        }
 
 out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
@@ -3155,7 +2781,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
 
 #undef CHK
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        for_each_context(priv, ctx) {
                ctx->staging.filter_flags &= ~filter_nand;
@@ -3167,7 +2793,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
                 */
        }
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        /*
         * Receiving all multicast frames is always enabled by the
@@ -3183,14 +2809,14 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop)
 {
        struct iwl_priv *priv = hw->priv;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
+       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) {
                IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n");
                goto done;
        }
-       if (iwl_is_rfkill(priv)) {
+       if (iwl_is_rfkill(priv->shrd)) {
                IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n");
                goto done;
        }
@@ -3207,9 +2833,9 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop)
                }
        }
        IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n");
-       iwlagn_wait_tx_queue_empty(priv);
+       iwl_trans_wait_tx_queue_empty(trans(priv));
 done:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
@@ -3217,7 +2843,7 @@ void iwlagn_disable_roc(struct iwl_priv *priv)
 {
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN];
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (!priv->hw_roc_setup)
                return;
@@ -3240,9 +2866,9 @@ static void iwlagn_disable_roc_work(struct work_struct *work)
        struct iwl_priv *priv = container_of(work, struct iwl_priv,
                                             hw_roc_disable_work.work);
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        iwlagn_disable_roc(priv);
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 static int iwl_mac_remain_on_channel(struct ieee80211_hw *hw,
@@ -3254,13 +2880,13 @@ static int iwl_mac_remain_on_channel(struct ieee80211_hw *hw,
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN];
        int err = 0;
 
-       if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
+       if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
                return -EOPNOTSUPP;
 
        if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)))
                return -EOPNOTSUPP;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        /*
         * TODO: Remove this hack! Firmware needs to be updated
@@ -3271,7 +2897,7 @@ static int iwl_mac_remain_on_channel(struct ieee80211_hw *hw,
        if (iwl_is_associated(priv, IWL_RXON_CTX_BSS) && duration > 80)
                duration = 80;
 
-       if (test_bit(STATUS_SCAN_HW, &priv->status)) {
+       if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) {
                err = -EBUSY;
                goto out;
        }
@@ -3310,7 +2936,7 @@ static int iwl_mac_remain_on_channel(struct ieee80211_hw *hw,
                iwlagn_disable_roc(priv);
 
  out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        return err;
 }
@@ -3319,17 +2945,83 @@ static int iwl_mac_cancel_remain_on_channel(struct ieee80211_hw *hw)
 {
        struct iwl_priv *priv = hw->priv;
 
-       if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
+       if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
                return -EOPNOTSUPP;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        iwl_scan_cancel_timeout(priv, priv->hw_roc_duration);
        iwlagn_disable_roc(priv);
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 
        return 0;
 }
 
+static int iwl_mac_tx_sync(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                          const u8 *bssid, enum ieee80211_tx_sync_type type)
+{
+       struct iwl_priv *priv = hw->priv;
+       struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
+       struct iwl_rxon_context *ctx = vif_priv->ctx;
+       int ret;
+       u8 sta_id;
+
+       mutex_lock(&priv->shrd->mutex);
+
+       if (iwl_is_associated_ctx(ctx)) {
+               ret = 0;
+               goto out;
+       }
+
+       if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, &priv->shrd->status)) {
+               ret = -EBUSY;
+               goto out;
+       }
+
+       ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id);
+       if (ret)
+               goto out;
+
+       if (WARN_ON(sta_id != ctx->ap_sta_id)) {
+               ret = -EIO;
+               goto out_remove_sta;
+       }
+
+       memcpy(ctx->bssid, bssid, ETH_ALEN);
+       ctx->preauth_bssid = true;
+
+       ret = iwlagn_commit_rxon(priv, ctx);
+
+       if (ret == 0)
+               goto out;
+
+ out_remove_sta:
+       iwl_remove_station(priv, sta_id, bssid);
+ out:
+       mutex_unlock(&priv->shrd->mutex);
+       return ret;
+}
+
+static void iwl_mac_finish_tx_sync(struct ieee80211_hw *hw,
+                                  struct ieee80211_vif *vif,
+                                  const u8 *bssid,
+                                  enum ieee80211_tx_sync_type type)
+{
+       struct iwl_priv *priv = hw->priv;
+       struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
+       struct iwl_rxon_context *ctx = vif_priv->ctx;
+
+       mutex_lock(&priv->shrd->mutex);
+
+       if (iwl_is_associated_ctx(ctx))
+               goto out;
+
+       iwl_remove_station(priv, ctx->ap_sta_id, bssid);
+       ctx->preauth_bssid = false;
+       /* no need to commit */
+ out:
+       mutex_unlock(&priv->shrd->mutex);
+}
+
 /*****************************************************************************
  *
  * driver setup and teardown
@@ -3338,9 +3030,9 @@ static int iwl_mac_cancel_remain_on_channel(struct ieee80211_hw *hw)
 
 static void iwl_setup_deferred_work(struct iwl_priv *priv)
 {
-       priv->workqueue = create_singlethread_workqueue(DRV_NAME);
+       priv->shrd->workqueue = create_singlethread_workqueue(DRV_NAME);
 
-       init_waitqueue_head(&priv->wait_command_queue);
+       init_waitqueue_head(&priv->shrd->wait_command_queue);
 
        INIT_WORK(&priv->restart, iwl_bg_restart);
        INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update);
@@ -3412,10 +3104,9 @@ static int iwl_init_drv(struct iwl_priv *priv)
 {
        int ret;
 
-       spin_lock_init(&priv->sta_lock);
-       spin_lock_init(&priv->hcmd_lock);
+       spin_lock_init(&priv->shrd->sta_lock);
 
-       mutex_init(&priv->mutex);
+       mutex_init(&priv->shrd->mutex);
 
        priv->ieee_channels = NULL;
        priv->ieee_rates = NULL;
@@ -3476,6 +3167,8 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
        iwl_calib_free_results(priv);
        iwl_free_geos(priv);
        iwl_free_channel_map(priv);
+       if (priv->tx_cmd_pool)
+               kmem_cache_destroy(priv->tx_cmd_pool);
        kfree(priv->scan_cmd);
        kfree(priv->beacon_cmd);
 #ifdef CONFIG_IWLWIFI_DEBUGFS
@@ -3488,7 +3181,7 @@ static void iwl_mac_rssi_callback(struct ieee80211_hw *hw,
 {
        struct iwl_priv *priv = hw->priv;
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        if (priv->cfg->bt_params &&
                        priv->cfg->bt_params->advanced_bt_coexist) {
@@ -3503,7 +3196,7 @@ static void iwl_mac_rssi_callback(struct ieee80211_hw *hw,
                                "ignoring RSSI callback\n");
        }
 
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 struct ieee80211_ops iwlagn_hw_ops = {
@@ -3537,27 +3230,38 @@ struct ieee80211_ops iwlagn_hw_ops = {
        .rssi_callback = iwl_mac_rssi_callback,
        CFG80211_TESTMODE_CMD(iwl_testmode_cmd)
        CFG80211_TESTMODE_DUMP(iwl_testmode_dump)
+       .tx_sync = iwl_mac_tx_sync,
+       .finish_tx_sync = iwl_mac_finish_tx_sync,
 };
 
 static u32 iwl_hw_detect(struct iwl_priv *priv)
 {
-       return iwl_read32(priv, CSR_HW_REV);
+       return iwl_read32(bus(priv), CSR_HW_REV);
 }
 
+/* Size of one Rx buffer in host DRAM */
+#define IWL_RX_BUF_SIZE_4K (4 * 1024)
+#define IWL_RX_BUF_SIZE_8K (8 * 1024)
+
 static int iwl_set_hw_params(struct iwl_priv *priv)
 {
-       priv->hw_params.max_rxq_size = RX_QUEUE_SIZE;
-       priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
        if (iwlagn_mod_params.amsdu_size_8K)
-               priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_8K);
+               hw_params(priv).rx_page_order =
+                       get_order(IWL_RX_BUF_SIZE_8K);
        else
-               priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_4K);
-
-       priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL;
+               hw_params(priv).rx_page_order =
+                       get_order(IWL_RX_BUF_SIZE_4K);
 
        if (iwlagn_mod_params.disable_11n)
                priv->cfg->sku &= ~EEPROM_SKU_CAP_11N_ENABLE;
 
+       hw_params(priv).num_ampdu_queues =
+               priv->cfg->base_params->num_of_ampdu_queues;
+       hw_params(priv).shadow_reg_enable =
+               priv->cfg->base_params->shadow_reg_enable;
+       hw_params(priv).sku = priv->cfg->sku;
+       hw_params(priv).wd_timeout = priv->cfg->base_params->wd_timeout;
+
        /* Device-specific setup */
        return priv->cfg->lib->set_hw_params(priv);
 }
@@ -3584,7 +3288,8 @@ out:
        return hw;
 }
 
-int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
+int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
+               struct iwl_cfg *cfg)
 {
        int err = 0;
        struct iwl_priv *priv;
@@ -3603,7 +3308,17 @@ int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
 
        priv = hw->priv;
        priv->bus = bus;
-       bus_set_drv_data(priv->bus, priv);
+       priv->shrd = &priv->_shrd;
+       priv->shrd->bus = bus;
+       priv->shrd->priv = priv;
+       priv->shrd->hw = hw;
+       bus_set_drv_data(priv->bus, priv->shrd);
+
+       priv->shrd->trans = trans_ops->alloc(priv->shrd);
+       if (priv->shrd->trans == NULL) {
+               err = -ENOMEM;
+               goto out_free_traffic_mem;
+       }
 
        /* At this point both hw and priv are allocated. */
 
@@ -3611,7 +3326,6 @@ int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
 
        IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
        priv->cfg = cfg;
-       priv->inta_mask = CSR_INI_SET_MASK;
 
        /* is antenna coupling more than 35dB ? */
        priv->bt_ant_couple_ok =
@@ -3630,15 +3344,15 @@ int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
        /* these spin locks will be used in apm_ops.init and EEPROM access
         * we should init now
         */
-       spin_lock_init(&priv->reg_lock);
-       spin_lock_init(&priv->lock);
+       spin_lock_init(&bus(priv)->reg_lock);
+       spin_lock_init(&priv->shrd->lock);
 
        /*
         * stop and reset the on-board processor just in case it is in a
         * strange state ... like being left stranded by a primary kernel
         * and this is now the kdump kernel trying to start up
         */
-       iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
+       iwl_write32(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
 
        /***********************
         * 3. Read REV register
@@ -3647,11 +3361,11 @@ int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
        IWL_INFO(priv, "Detected %s, REV=0x%X\n",
                priv->cfg->name, hw_rev);
 
-       err = iwl_trans_register(&priv->trans, priv);
+       err = iwl_trans_request_irq(trans(priv));
        if (err)
-               goto out_free_traffic_mem;
+               goto out_free_trans;
 
-       if (trans_prepare_card_hw(&priv->trans)) {
+       if (iwl_trans_prepare_card_hw(trans(priv))) {
                err = -EIO;
                IWL_WARN(priv, "Failed, HW not ready\n");
                goto out_free_trans;
@@ -3719,13 +3433,14 @@ int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
        iwl_enable_rfkill_int(priv);
 
        /* If platform's RF_KILL switch is NOT set to KILL */
-       if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
-               clear_bit(STATUS_RF_KILL_HW, &priv->status);
+       if (iwl_read32(bus(priv),
+                       CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
+               clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
        else
-               set_bit(STATUS_RF_KILL_HW, &priv->status);
+               set_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
 
        wiphy_rfkill_set_hw_state(priv->hw->wiphy,
-               test_bit(STATUS_RF_KILL_HW, &priv->status));
+               test_bit(STATUS_RF_KILL_HW, &priv->shrd->status));
 
        iwl_power_initialize(priv);
        iwl_tt_initialize(priv);
@@ -3739,13 +3454,13 @@ int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
        return 0;
 
 out_destroy_workqueue:
-       destroy_workqueue(priv->workqueue);
-       priv->workqueue = NULL;
+       destroy_workqueue(priv->shrd->workqueue);
+       priv->shrd->workqueue = NULL;
        iwl_uninit_drv(priv);
 out_free_eeprom:
        iwl_eeprom_free(priv);
 out_free_trans:
-       trans_free(&priv->trans);
+       iwl_trans_free(trans(priv));
 out_free_traffic_mem:
        iwl_free_traffic_mem(priv);
        ieee80211_free_hw(priv->hw);
@@ -3755,8 +3470,6 @@ out:
 
 void __devexit iwl_remove(struct iwl_priv * priv)
 {
-       unsigned long flags;
-
        wait_for_completion(&priv->firmware_loading_complete);
 
        IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
@@ -3769,48 +3482,36 @@ void __devexit iwl_remove(struct iwl_priv * priv)
         * to be called and iwl_down since we are removing the device
         * we need to set STATUS_EXIT_PENDING bit.
         */
-       set_bit(STATUS_EXIT_PENDING, &priv->status);
+       set_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
 
        iwl_testmode_cleanup(priv);
        iwl_leds_exit(priv);
 
-       if (priv->mac80211_registered) {
+       if (priv->shrd->mac80211_registered) {
                ieee80211_unregister_hw(priv->hw);
-               priv->mac80211_registered = 0;
+               priv->shrd->mac80211_registered = 0;
        }
 
-       /* Reset to low power before unloading driver. */
-       iwl_apm_stop(priv);
-
        iwl_tt_exit(priv);
 
-       /* make sure we flush any pending irq or
-        * tasklet for the driver
-        */
-       spin_lock_irqsave(&priv->lock, flags);
-       iwl_disable_interrupts(priv);
-       spin_unlock_irqrestore(&priv->lock, flags);
-
-       trans_sync_irq(&priv->trans);
+       /*This will stop the queues, move the device to low power state */
+       iwl_trans_stop_device(trans(priv));
 
        iwl_dealloc_ucode(priv);
 
-       trans_rx_free(&priv->trans);
-       trans_tx_free(&priv->trans);
-
        iwl_eeprom_free(priv);
 
        /*netif_stop_queue(dev); */
-       flush_workqueue(priv->workqueue);
+       flush_workqueue(priv->shrd->workqueue);
 
        /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes
-        * priv->workqueue... so we can't take down the workqueue
+        * priv->shrd->workqueue... so we can't take down the workqueue
         * until now... */
-       destroy_workqueue(priv->workqueue);
-       priv->workqueue = NULL;
+       destroy_workqueue(priv->shrd->workqueue);
+       priv->shrd->workqueue = NULL;
        iwl_free_traffic_mem(priv);
 
-       trans_free(&priv->trans);
+       iwl_trans_free(trans(priv));
 
        bus_set_drv_data(priv->bus, NULL);
 
@@ -3892,7 +3593,7 @@ MODULE_PARM_DESC(antenna_coupling,
 module_param_named(bt_ch_inhibition, iwlagn_mod_params.bt_ch_announce,
                   bool, S_IRUGO);
 MODULE_PARM_DESC(bt_ch_inhibition,
-                "Disable BT channel inhibition (default: enable)");
+                "Enable BT channel inhibition (default: enable)");
 
 module_param_named(plcp_check, iwlagn_mod_params.plcp_check, bool, S_IRUGO);
 MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])");
@@ -3938,6 +3639,11 @@ module_param_named(power_level, iwlagn_mod_params.power_level,
 MODULE_PARM_DESC(power_level,
                 "default power save level (range from 1 - 5, default: 1)");
 
+module_param_named(auto_agg, iwlagn_mod_params.auto_agg,
+               bool, S_IRUGO);
+MODULE_PARM_DESC(auto_agg,
+                "enable agg w/o check traffic load (default: enable)");
+
 /*
  * For now, keep using power level 1 instead of automatically
  * adjusting ...
This page took 0.088795 seconds and 5 git commands to generate.