]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-sta.c
Merge branch 'fix/asoc' into for-linus
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / iwlwifi / iwl-sta.c
index 6283a3a707f58dad2f5cb17bfcb82ed05a57a148..26f7084d3011b7f8f514a4e23090ddfce33ca62c 100644 (file)
@@ -47,8 +47,8 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
        unsigned long flags;
        DECLARE_MAC_BUF(mac);
 
-       if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) ||
-           (priv->iw_mode == IEEE80211_IF_TYPE_AP))
+       if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
+           (priv->iw_mode == NL80211_IFTYPE_AP))
                start = IWL_STA_ID;
 
        if (is_broadcast_ether_addr(addr))
@@ -74,7 +74,7 @@ EXPORT_SYMBOL(iwl_find_station);
 
 int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
 {
-       if (priv->iw_mode == IEEE80211_IF_TYPE_STA) {
+       if (priv->iw_mode == NL80211_IFTYPE_STATION) {
                return IWL_AP_ID;
        } else {
                u8 *da = ieee80211_get_DA(hdr);
@@ -191,20 +191,20 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
        if (!sta_ht_inf || !sta_ht_inf->ht_supported)
                goto done;
 
-       mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2;
+       mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
 
        sta_flags = priv->stations[index].sta.station_flags;
 
        sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK);
 
        switch (mimo_ps_mode) {
-       case WLAN_HT_CAP_MIMO_PS_STATIC:
+       case WLAN_HT_CAP_SM_PS_STATIC:
                sta_flags |= STA_FLG_MIMO_DIS_MSK;
                break;
-       case WLAN_HT_CAP_MIMO_PS_DYNAMIC:
+       case WLAN_HT_CAP_SM_PS_DYNAMIC:
                sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK;
                break;
-       case WLAN_HT_CAP_MIMO_PS_DISABLED:
+       case WLAN_HT_CAP_SM_PS_DISABLED:
                break;
        default:
                IWL_WARNING("Invalid MIMO PS mode %d\n", mimo_ps_mode);
@@ -286,7 +286,7 @@ u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
 
        /* BCAST station and IBSS stations do not work in HT mode */
        if (sta_id != priv->hw_params.bcast_sta_id &&
-           priv->iw_mode != IEEE80211_IF_TYPE_IBSS)
+           priv->iw_mode != NL80211_IFTYPE_ADHOC)
                iwl_set_ht_add_station(priv, sta_id, ht_info);
 
        spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
@@ -475,7 +475,7 @@ static int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
                if (!test_and_set_bit(i, &priv->ucode_key_table))
                        return i;
 
-       return -1;
+       return WEP_INVALID_OFFSET;
 }
 
 int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
@@ -620,6 +620,9 @@ static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
        /* else, we are overriding an existing key => no need to allocated room
         * in uCode. */
 
+       WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
+               "no space for new kew");
+
        priv->stations[sta_id].sta.key.key_flags = key_flags;
        priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
        priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
@@ -637,6 +640,7 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
 {
        unsigned long flags;
        __le16 key_flags = 0;
+       int ret;
 
        key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
        key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
@@ -664,14 +668,18 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
        /* else, we are overriding an existing key => no need to allocated room
         * in uCode. */
 
+       WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
+               "no space for new kew");
+
        priv->stations[sta_id].sta.key.key_flags = key_flags;
        priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
        priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
 
+       ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
+
        spin_unlock_irqrestore(&priv->sta_lock, flags);
 
-       IWL_DEBUG_INFO("hwcrypto: modify ucode station key info\n");
-       return iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
+       return ret;
 }
 
 static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
@@ -696,6 +704,9 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
        /* else, we are overriding an existing key => no need to allocated room
         * in uCode. */
 
+       WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
+               "no space for new kew");
+
        /* This copy is acutally not needed: we get the key with each TX */
        memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
 
@@ -734,6 +745,13 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
                return 0;
        }
 
+       if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) {
+               IWL_WARNING("Removing wrong key %d 0x%x\n",
+                           keyconf->keyidx, key_flags);
+               spin_unlock_irqrestore(&priv->sta_lock, flags);
+               return 0;
+       }
+
        if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset,
                &priv->ucode_key_table))
                IWL_ERROR("index %d not used in uCode key table.\n",
@@ -817,7 +835,7 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
        };
 
        if ((lq->sta_id == 0xFF) &&
-           (priv->iw_mode == IEEE80211_IF_TYPE_IBSS))
+           (priv->iw_mode == NL80211_IFTYPE_ADHOC))
                return -EINVAL;
 
        if (lq->sta_id == 0xFF)
@@ -904,7 +922,7 @@ int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
 
        if ((is_ap) &&
            (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) &&
-           (priv->iw_mode == IEEE80211_IF_TYPE_STA))
+           (priv->iw_mode == NL80211_IFTYPE_STATION))
                sta_id = iwl_add_station_flags(priv, addr, is_ap,
                                                   0, cur_ht_config);
        else
@@ -938,11 +956,11 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
 
        /* If we are a client station in a BSS network, use the special
         * AP station entry (that's the only station we communicate with) */
-       case IEEE80211_IF_TYPE_STA:
+       case NL80211_IFTYPE_STATION:
                return IWL_AP_ID;
 
        /* If we are an AP, then find the station, or use BCAST */
-       case IEEE80211_IF_TYPE_AP:
+       case NL80211_IFTYPE_AP:
                sta_id = iwl_find_station(priv, hdr->addr1);
                if (sta_id != IWL_INVALID_STATION)
                        return sta_id;
@@ -950,7 +968,7 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
 
        /* If this frame is going out to an IBSS network, find the station,
         * or create a new station table entry */
-       case IEEE80211_IF_TYPE_IBSS:
+       case NL80211_IFTYPE_ADHOC:
                sta_id = iwl_find_station(priv, hdr->addr1);
                if (sta_id != IWL_INVALID_STATION)
                        return sta_id;
@@ -968,6 +986,11 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
                iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
                return priv->hw_params.bcast_sta_id;
 
+       /* If we are in monitor mode, use BCAST. This is required for
+        * packet injection. */
+       case NL80211_IFTYPE_MONITOR:
+               return priv->hw_params.bcast_sta_id;
+
        default:
                IWL_WARNING("Unknown mode of operation: %d\n", priv->iw_mode);
                return priv->hw_params.bcast_sta_id;