iwlagn: enable 11n aggregation without checking traffic load
[cascardo/linux.git] / drivers / net / wireless / iwlwifi / iwl-agn-lib.c
index 3bee0f1..6cfd236 100644 (file)
@@ -40,6 +40,7 @@
 #include "iwl-agn.h"
 #include "iwl-sta.h"
 #include "iwl-trans.h"
+#include "iwl-shared.h"
 
 static inline u32 iwlagn_get_scd_ssn(struct iwlagn_tx_resp *tx_resp)
 {
@@ -386,8 +387,8 @@ void iwl_check_abort_status(struct iwl_priv *priv,
 {
        if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) {
                IWL_ERR(priv, "Tx flush command to flush out all frames\n");
-               if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
-                       queue_work(priv->workqueue, &priv->tx_flush);
+               if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
+                       queue_work(priv->shrd->workqueue, &priv->tx_flush);
        }
 }
 
@@ -426,7 +427,7 @@ void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
        sta_id = (tx_resp->ra_tid & IWLAGN_TX_RES_RA_MSK) >>
                IWLAGN_TX_RES_RA_POS;
 
-       spin_lock_irqsave(&priv->sta_lock, flags);
+       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
 
        hdr = (void *)txb->skb->data;
        if (!ieee80211_is_data_qos(hdr->frame_control))
@@ -481,7 +482,7 @@ void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
        iwlagn_txq_check_empty(priv, sta_id, tid, txq_id);
 
        iwl_check_abort_status(priv, tx_resp->frame_count, status);
-       spin_unlock_irqrestore(&priv->sta_lock, flags);
+       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
 }
 
 int iwlagn_hw_valid_rtc_data_addr(u32 addr)
@@ -495,7 +496,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
        struct iwlagn_tx_power_dbm_cmd tx_power_cmd;
        u8 tx_ant_cfg_cmd;
 
-       if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+       if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->shrd->status),
                      "TX Power requested while scanning!\n"))
                return -EAGAIN;
 
@@ -525,7 +526,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
        else
                tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
 
-       return trans_send_cmd_pdu(&priv->trans, tx_ant_cfg_cmd, CMD_SYNC,
+       return iwl_trans_send_cmd_pdu(trans(priv), tx_ant_cfg_cmd, CMD_SYNC,
                        sizeof(tx_power_cmd), &tx_power_cmd);
 }
 
@@ -609,6 +610,9 @@ struct iwl_mod_params iwlagn_mod_params = {
        .bt_coex_active = true,
        .no_sleep_autoadjust = true,
        .power_level = IWL_POWER_INDEX_1,
+       .bt_ch_announce = 1,
+       .wanted_ucode_alternative = 1,
+       .auto_agg = true,
        /* the rest are 0 by default */
 };
 
@@ -753,18 +757,6 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
        return added;
 }
 
-static int iwl_fill_offch_tx(struct iwl_priv *priv, void *data, size_t maxlen)
-{
-       struct sk_buff *skb = priv->offchan_tx_skb;
-
-       if (skb->len < maxlen)
-               maxlen = skb->len;
-
-       memcpy(data, skb->data, maxlen);
-
-       return maxlen;
-}
-
 int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
 {
        struct iwl_host_cmd cmd = {
@@ -779,15 +771,15 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        u16 rx_chain = 0;
        enum ieee80211_band band;
        u8 n_probes = 0;
-       u8 rx_ant = priv->hw_params.valid_rx_ant;
+       u8 rx_ant = hw_params(priv).valid_rx_ant;
        u8 rate;
        bool is_active = false;
        int  chan_mod;
        u8 active_chains;
-       u8 scan_tx_antennas = priv->hw_params.valid_tx_ant;
+       u8 scan_tx_antennas = hw_params(priv).valid_tx_ant;
        int ret;
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        if (vif)
                ctx = iwl_rxon_ctx_from_vif(vif);
@@ -807,7 +799,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
        scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
 
-       if (priv->scan_type != IWL_SCAN_OFFCH_TX &&
+       if (priv->scan_type != IWL_SCAN_ROC &&
            iwl_is_any_associated(priv)) {
                u16 interval = 0;
                u32 extra;
@@ -816,7 +808,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
 
                IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
                switch (priv->scan_type) {
-               case IWL_SCAN_OFFCH_TX:
+               case IWL_SCAN_ROC:
                        WARN_ON(1);
                        break;
                case IWL_SCAN_RADIO_RESET:
@@ -838,10 +830,11 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                scan->suspend_time = cpu_to_le32(scan_suspend_time);
                IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n",
                               scan_suspend_time, interval);
-       } else if (priv->scan_type == IWL_SCAN_OFFCH_TX) {
+       } else if (priv->scan_type == IWL_SCAN_ROC) {
                scan->suspend_time = 0;
-               scan->max_out_time =
-                       cpu_to_le32(1024 * priv->offchan_tx_timeout);
+               scan->max_out_time = 0;
+               scan->quiet_time = 0;
+               scan->quiet_plcp_th = 0;
        }
 
        switch (priv->scan_type) {
@@ -869,8 +862,8 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                } else
                        IWL_DEBUG_SCAN(priv, "Start passive scan.\n");
                break;
-       case IWL_SCAN_OFFCH_TX:
-               IWL_DEBUG_SCAN(priv, "Start offchannel TX scan.\n");
+       case IWL_SCAN_ROC:
+               IWL_DEBUG_SCAN(priv, "Start ROC scan.\n");
                break;
        }
 
@@ -953,7 +946,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
 
        /* In power save mode use one chain, otherwise use all chains */
-       if (test_bit(STATUS_POWER_PMI, &priv->status)) {
+       if (test_bit(STATUS_POWER_PMI, &priv->shrd->status)) {
                /* rx_ant has been set to all valid chains previously */
                active_chains = rx_ant &
                                ((u8)(priv->chain_noise_data.active_chains));
@@ -973,7 +966,8 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        }
 
        /* MIMO is not used here, but value is required */
-       rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
+       rx_chain |=
+               hw_params(priv).valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
        rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
        rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
        rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
@@ -988,19 +982,13 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                                        IWL_MAX_SCAN_SIZE - sizeof(*scan));
                break;
        case IWL_SCAN_RADIO_RESET:
+       case IWL_SCAN_ROC:
                /* use bcast addr, will not be transmitted but must be valid */
                cmd_len = iwl_fill_probe_req(priv,
                                        (struct ieee80211_mgmt *)scan->data,
                                        iwl_bcast_addr, NULL, 0,
                                        IWL_MAX_SCAN_SIZE - sizeof(*scan));
                break;
-       case IWL_SCAN_OFFCH_TX:
-               cmd_len = iwl_fill_offch_tx(priv, scan->data,
-                                           IWL_MAX_SCAN_SIZE
-                                            - sizeof(*scan)
-                                            - sizeof(struct iwl_scan_channel));
-               scan->scan_flags |= IWL_SCAN_FLAGS_ACTION_FRAME_TX;
-               break;
        default:
                BUG();
        }
@@ -1021,18 +1009,18 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                                is_active, n_probes,
                                (void *)&scan->data[cmd_len]);
                break;
-       case IWL_SCAN_OFFCH_TX: {
+       case IWL_SCAN_ROC: {
                struct iwl_scan_channel *scan_ch;
 
                scan->channel_count = 1;
 
                scan_ch = (void *)&scan->data[cmd_len];
-               scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
+               scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
                scan_ch->channel =
-                       cpu_to_le16(priv->offchan_tx_chan->hw_value);
+                       cpu_to_le16(priv->hw_roc_channel->hw_value);
                scan_ch->active_dwell =
-                       cpu_to_le16(priv->offchan_tx_timeout);
-               scan_ch->passive_dwell = 0;
+               scan_ch->passive_dwell =
+                       cpu_to_le16(priv->hw_roc_duration);
 
                /* Set txpower levels to defaults */
                scan_ch->dsp_atten = 110;
@@ -1041,7 +1029,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
                 * power level:
                 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
                 */
-               if (priv->offchan_tx_chan->band == IEEE80211_BAND_5GHZ)
+               if (priv->hw_roc_channel->band == IEEE80211_BAND_5GHZ)
                        scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
                else
                        scan_ch->tx_gain = ((1 << 5) | (5 << 3));
@@ -1061,15 +1049,15 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        scan->len = cpu_to_le16(cmd.len[0]);
 
        /* set scan bit here for PAN params */
-       set_bit(STATUS_SCAN_HW, &priv->status);
+       set_bit(STATUS_SCAN_HW, &priv->shrd->status);
 
        ret = iwlagn_set_pan_params(priv);
        if (ret)
                return ret;
 
-       ret = trans_send_cmd(&priv->trans, &cmd);
+       ret = iwl_trans_send_cmd(trans(priv), &cmd);
        if (ret) {
-               clear_bit(STATUS_SCAN_HW, &priv->status);
+               clear_bit(STATUS_SCAN_HW, &priv->shrd->status);
                iwlagn_set_pan_params(priv);
        }
 
@@ -1092,7 +1080,7 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv,
 void iwl_free_tfds_in_queue(struct iwl_priv *priv,
                            int sta_id, int tid, int freed)
 {
-       lockdep_assert_held(&priv->sta_lock);
+       lockdep_assert_held(&priv->shrd->sta_lock);
 
        if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed)
                priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
@@ -1115,8 +1103,8 @@ int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv)
        int ret = 0;
 
        /* waiting for all the tx frames complete might take a while */
-       for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
-               if (cnt == priv->cmd_queue)
+       for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) {
+               if (cnt == priv->shrd->cmd_queue)
                        continue;
                txq = &priv->txq[cnt];
                q = &txq->q;
@@ -1173,12 +1161,12 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
                       flush_cmd.fifo_control);
        flush_cmd.flush_control = cpu_to_le16(flush_control);
 
-       return trans_send_cmd(&priv->trans, &cmd);
+       return iwl_trans_send_cmd(trans(priv), &cmd);
 }
 
 void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
 {
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
        ieee80211_stop_queues(priv->hw);
        if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) {
                IWL_ERR(priv, "flush request fail\n");
@@ -1188,7 +1176,7 @@ void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
        iwlagn_wait_tx_queue_empty(priv);
 done:
        ieee80211_wake_queues(priv->hw);
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 /*
@@ -1367,12 +1355,12 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
        if (priv->cfg->bt_params->bt_session_2) {
                memcpy(&bt_cmd_2000.basic, &basic,
                        sizeof(basic));
-               ret = trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
+               ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
                        CMD_SYNC, sizeof(bt_cmd_2000), &bt_cmd_2000);
        } else {
                memcpy(&bt_cmd_6000.basic, &basic,
                        sizeof(basic));
-               ret = trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
+               ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
                        CMD_SYNC, sizeof(bt_cmd_6000), &bt_cmd_6000);
        }
        if (ret)
@@ -1385,7 +1373,7 @@ void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena)
        struct iwl_rxon_context *ctx, *found_ctx = NULL;
        bool found_ap = false;
 
-       lockdep_assert_held(&priv->mutex);
+       lockdep_assert_held(&priv->shrd->mutex);
 
        /* Check whether AP or GO mode is active. */
        if (rssi_ena) {
@@ -1498,7 +1486,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
                break;
        }
 
-       mutex_lock(&priv->mutex);
+       mutex_lock(&priv->shrd->mutex);
 
        /*
         * We can not send command to firmware while scanning. When the scan
@@ -1507,7 +1495,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
         * STATUS_SCANNING to avoid race when queue_work two times from
         * different notifications, but quit and not perform any work at all.
         */
-       if (test_bit(STATUS_SCAN_HW, &priv->status))
+       if (test_bit(STATUS_SCAN_HW, &priv->shrd->status))
                goto out;
 
        iwl_update_chain_flags(priv);
@@ -1526,7 +1514,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
         */
        iwlagn_bt_coex_rssi_monitor(priv);
 out:
-       mutex_unlock(&priv->mutex);
+       mutex_unlock(&priv->shrd->mutex);
 }
 
 /*
@@ -1633,7 +1621,7 @@ static void iwlagn_set_kill_msk(struct iwl_priv *priv,
                priv->kill_cts_mask = bt_kill_cts_msg[kill_msk];
 
                /* schedule to send runtime bt_config */
-               queue_work(priv->workqueue, &priv->bt_runtime_config);
+               queue_work(priv->shrd->workqueue, &priv->bt_runtime_config);
        }
 }
 
@@ -1677,7 +1665,7 @@ void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
                                        IWL_BT_COEX_TRAFFIC_LOAD_NONE;
                        }
                        priv->bt_status = coex->bt_status;
-                       queue_work(priv->workqueue,
+                       queue_work(priv->shrd->workqueue,
                                   &priv->bt_traffic_change_work);
                }
        }
@@ -1686,9 +1674,9 @@ void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
 
        /* FIXME: based on notification, adjust the prio_boost */
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->shrd->lock, flags);
        priv->bt_ci_compliance = coex->bt_ci_compliance;
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->shrd->lock, flags);
 }
 
 void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv)
@@ -1788,7 +1776,7 @@ static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
 void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 {
        bool is_single = is_single_rx_stream(priv);
-       bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
+       bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->shrd->status);
        u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt;
        u32 active_chains;
        u16 rx_chain;
@@ -1800,7 +1788,7 @@ void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
        if (priv->chain_noise_data.active_chains)
                active_chains = priv->chain_noise_data.active_chains;
        else
-               active_chains = priv->hw_params.valid_rx_ant;
+               active_chains = hw_params(priv).valid_rx_ant;
 
        if (priv->cfg->bt_params &&
            priv->cfg->bt_params->advanced_bt_coexist &&