]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-core.c
iwl3945: use iwl_set_mode in 3945
[karo-tx-linux.git] / drivers / net / wireless / iwlwifi / iwl-core.c
index 7609bfced10f97eadcfd38d193cd668950c24e68..01e7604bf33f3ba274a435af0a1c556324163b1d 100644 (file)
@@ -821,7 +821,8 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
 
        rxon->flags |= cpu_to_le32(val << RXON_FLG_HT_OPERATING_MODE_POS);
 
-       iwl_set_rxon_chain(priv);
+       if (priv->cfg->ops->hcmd->set_rxon_chain)
+               priv->cfg->ops->hcmd->set_rxon_chain(priv);
 
        IWL_DEBUG_ASSOC(priv, "supported HT rate 0x%X 0x%X 0x%X "
                        "rxon flags 0x%X operation mode :0x%X "
@@ -1117,6 +1118,7 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
        memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN);
        priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
        priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
+       priv->staging_rxon.ofdm_ht_triple_stream_basic_rates = 0xff;
 }
 EXPORT_SYMBOL(iwl_connection_init_rx_config);
 
@@ -1306,6 +1308,7 @@ int iwl_setup_mac(struct iwl_priv *priv)
 
        hw->wiphy->custom_regulatory = true;
        hw->wiphy->max_scan_ssids = 1;
+       hw->wiphy->max_scan_ie_len = 0; /* XXX for now */
 
        /* Default value; 4 EDCA QOS priorities */
        hw->queues = 4;
@@ -1366,7 +1369,7 @@ int iwl_init_drv(struct iwl_priv *priv)
        mutex_init(&priv->mutex);
 
        /* Clear the driver's (not device's) station table */
-       iwl_clear_stations_table(priv);
+       priv->cfg->ops->smgmt->clear_station_table(priv);
 
        priv->data_retry_limit = -1;
        priv->ieee_channels = NULL;
@@ -1378,7 +1381,9 @@ int iwl_init_drv(struct iwl_priv *priv)
        priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED;
 
        /* Choose which receivers/antennas to use */
-       iwl_set_rxon_chain(priv);
+       if (priv->cfg->ops->hcmd->set_rxon_chain)
+               priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
        iwl_init_scan_params(priv);
 
        iwl_reset_qos(priv);
@@ -2054,7 +2059,7 @@ void iwl_bg_rf_kill(struct work_struct *work)
                          "HW and/or SW RF Kill no longer active, restarting "
                          "device\n");
                if (!test_bit(STATUS_EXIT_PENDING, &priv->status) &&
-                   test_bit(STATUS_ALIVE, &priv->status))
+                   priv->is_open)
                        queue_work(priv->workqueue, &priv->restart);
        } else {
                /* make sure mac80211 stop sending Tx frame */
@@ -2155,6 +2160,227 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
        return 0;
 }
 EXPORT_SYMBOL(iwl_mac_conf_tx);
+
+static void iwl_ht_conf(struct iwl_priv *priv,
+                           struct ieee80211_bss_conf *bss_conf)
+{
+       struct ieee80211_sta_ht_cap *ht_conf;
+       struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
+       struct ieee80211_sta *sta;
+
+       IWL_DEBUG_MAC80211(priv, "enter: \n");
+
+       if (!iwl_conf->is_ht)
+               return;
+
+
+       /*
+        * It is totally wrong to base global information on something
+        * that is valid only when associated, alas, this driver works
+        * that way and I don't know how to fix it.
+        */
+
+       rcu_read_lock();
+       sta = ieee80211_find_sta(priv->hw, priv->bssid);
+       if (!sta) {
+               rcu_read_unlock();
+               return;
+       }
+       ht_conf = &sta->ht_cap;
+
+       if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20)
+               iwl_conf->sgf |= HT_SHORT_GI_20MHZ;
+       if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40)
+               iwl_conf->sgf |= HT_SHORT_GI_40MHZ;
+
+       iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD);
+       iwl_conf->max_amsdu_size =
+               !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU);
+
+       iwl_conf->supported_chan_width =
+               !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
+
+       /*
+        * XXX: The HT configuration needs to be moved into iwl_mac_config()
+        *      to be done there correctly.
+        */
+
+       iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
+       if (conf_is_ht40_minus(&priv->hw->conf))
+               iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
+       else if (conf_is_ht40_plus(&priv->hw->conf))
+               iwl_conf->extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
+
+       /* If no above or below channel supplied disable FAT channel */
+       if (iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_ABOVE &&
+           iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_BELOW)
+               iwl_conf->supported_chan_width = 0;
+
+       iwl_conf->sm_ps = (u8)((ht_conf->cap & IEEE80211_HT_CAP_SM_PS) >> 2);
+
+       memcpy(&iwl_conf->mcs, &ht_conf->mcs, 16);
+
+       iwl_conf->tx_chan_width = iwl_conf->supported_chan_width != 0;
+       iwl_conf->ht_protection =
+               bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
+       iwl_conf->non_GF_STA_present =
+               !!(bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
+
+       rcu_read_unlock();
+
+       IWL_DEBUG_MAC80211(priv, "leave\n");
+}
+
+#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
+void iwl_bss_info_changed(struct ieee80211_hw *hw,
+                                    struct ieee80211_vif *vif,
+                                    struct ieee80211_bss_conf *bss_conf,
+                                    u32 changes)
+{
+       struct iwl_priv *priv = hw->priv;
+
+       IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
+
+       if (changes & BSS_CHANGED_ERP_PREAMBLE) {
+               IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
+                                  bss_conf->use_short_preamble);
+               if (bss_conf->use_short_preamble)
+                       priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
+               else
+                       priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
+       }
+
+       if (changes & BSS_CHANGED_ERP_CTS_PROT) {
+               IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
+               if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
+                       priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
+               else
+                       priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
+       }
+
+       if (changes & BSS_CHANGED_HT) {
+               iwl_ht_conf(priv, bss_conf);
+
+               if (priv->cfg->ops->hcmd->set_rxon_chain)
+                       priv->cfg->ops->hcmd->set_rxon_chain(priv);
+       }
+
+       if (changes & BSS_CHANGED_ASSOC) {
+               IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
+               /* This should never happen as this function should
+                * never be called from interrupt context. */
+               if (WARN_ON_ONCE(in_interrupt()))
+                       return;
+               if (bss_conf->assoc) {
+                       priv->assoc_id = bss_conf->aid;
+                       priv->beacon_int = bss_conf->beacon_int;
+                       priv->power_data.dtim_period = bss_conf->dtim_period;
+                       priv->timestamp = bss_conf->timestamp;
+                       priv->assoc_capability = bss_conf->assoc_capability;
+
+                       /* we have just associated, don't start scan too early
+                        * leave time for EAPOL exchange to complete
+                        */
+                       priv->next_scan_jiffies = jiffies +
+                                       IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
+                       mutex_lock(&priv->mutex);
+                       priv->cfg->ops->lib->post_associate(priv);
+                       mutex_unlock(&priv->mutex);
+               } else {
+                       priv->assoc_id = 0;
+                       IWL_DEBUG_MAC80211(priv, "DISASSOC %d\n", bss_conf->assoc);
+               }
+       } else if (changes && iwl_is_associated(priv) && priv->assoc_id) {
+                       IWL_DEBUG_MAC80211(priv, "Associated Changes %d\n", changes);
+                       iwl_send_rxon_assoc(priv);
+       }
+
+}
+EXPORT_SYMBOL(iwl_bss_info_changed);
+
+int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+       struct iwl_priv *priv = hw->priv;
+       unsigned long flags;
+       __le64 timestamp;
+
+       IWL_DEBUG_MAC80211(priv, "enter\n");
+
+       if (!iwl_is_ready_rf(priv)) {
+               IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
+               return -EIO;
+       }
+
+       if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
+               IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
+               return -EIO;
+       }
+
+       spin_lock_irqsave(&priv->lock, flags);
+
+       if (priv->ibss_beacon)
+               dev_kfree_skb(priv->ibss_beacon);
+
+       priv->ibss_beacon = skb;
+
+       priv->assoc_id = 0;
+       timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
+       priv->timestamp = le64_to_cpu(timestamp);
+
+       IWL_DEBUG_MAC80211(priv, "leave\n");
+       spin_unlock_irqrestore(&priv->lock, flags);
+
+       iwl_reset_qos(priv);
+
+       priv->cfg->ops->lib->post_associate(priv);
+
+
+       return 0;
+}
+EXPORT_SYMBOL(iwl_mac_beacon_update);
+
+int iwl_set_mode(struct iwl_priv *priv, int mode)
+{
+       if (mode == NL80211_IFTYPE_ADHOC) {
+               const struct iwl_channel_info *ch_info;
+
+               ch_info = iwl_get_channel_info(priv,
+                       priv->band,
+                       le16_to_cpu(priv->staging_rxon.channel));
+
+               if (!ch_info || !is_channel_ibss(ch_info)) {
+                       IWL_ERR(priv, "channel %d not IBSS channel\n",
+                                 le16_to_cpu(priv->staging_rxon.channel));
+                       return -EINVAL;
+               }
+       }
+
+       iwl_connection_init_rx_config(priv, mode);
+
+       if (priv->cfg->ops->hcmd->set_rxon_chain)
+               priv->cfg->ops->hcmd->set_rxon_chain(priv);
+
+       memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
+
+       priv->cfg->ops->smgmt->clear_station_table(priv);
+
+       /* dont commit rxon if rf-kill is on*/
+       if (!iwl_is_ready_rf(priv))
+               return -EAGAIN;
+
+       cancel_delayed_work(&priv->scan_check);
+       if (iwl_scan_cancel_timeout(priv, 100)) {
+               IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
+               IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
+               return -EAGAIN;
+       }
+
+       iwlcore_commit_rxon(priv);
+
+       return 0;
+}
+EXPORT_SYMBOL(iwl_set_mode);
+
 #ifdef CONFIG_PM
 
 int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)