[MAC80211]: clean up whitespace
[pandora-kernel.git] / net / mac80211 / ieee80211_ioctl.c
index e7904db..383ad5f 100644 (file)
 #include "ieee80211_rate.h"
 #include "wpa.h"
 #include "aes_ccm.h"
-#include "debugfs_key.h"
-
-static void ieee80211_set_hw_encryption(struct net_device *dev,
-                                       struct sta_info *sta, u8 addr[ETH_ALEN],
-                                       struct ieee80211_key *key)
-{
-       struct ieee80211_key_conf *keyconf = NULL;
-       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
-
-       /* default to sw encryption; this will be cleared by low-level
-        * driver if the hw supports requested encryption */
-       if (key)
-               key->force_sw_encrypt = 1;
-
-       if (key && local->ops->set_key &&
-           (keyconf = ieee80211_key_data2conf(local, key))) {
-               if (local->ops->set_key(local_to_hw(local), SET_KEY, addr,
-                                      keyconf, sta ? sta->aid : 0)) {
-                       key->force_sw_encrypt = 1;
-                       key->hw_key_idx = HW_KEY_IDX_INVALID;
-               } else {
-                       key->force_sw_encrypt =
-                               !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
-                       key->hw_key_idx =
-                               keyconf->hw_key_idx;
-
-               }
-       }
-       kfree(keyconf);
-}
-
 
 static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
                                    int idx, int alg, int set_tx_key,
@@ -64,9 +33,7 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        int ret = 0;
        struct sta_info *sta;
-       struct ieee80211_key *key, *old_key;
-       int try_hwaccel = 1;
-       struct ieee80211_key_conf *keyconf;
+       struct ieee80211_key *key;
        struct ieee80211_sub_if_data *sdata;
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -79,16 +46,6 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
                        return -EINVAL;
                }
                key = sdata->keys[idx];
-
-               /* TODO: consider adding hwaccel support for these; at least
-                * Atheros key cache should be able to handle this since AP is
-                * only transmitting frames with default keys. */
-               /* FIX: hw key cache can be used when only one virtual
-                * STA is associated with each AP. If more than one STA
-                * is associated to the same AP, software encryption
-                * must be used. This should be done automatically
-                * based on configured station devices. For the time
-                * being, this can be only set at compile time. */
        } else {
                set_tx_key = 0;
                if (idx != 0) {
@@ -111,144 +68,28 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
                key = sta->key;
        }
 
-       /* FIX:
-        * Cannot configure default hwaccel keys with WEP algorithm, if
-        * any of the virtual interfaces is using static WEP
-        * configuration because hwaccel would otherwise try to decrypt
-        * these frames.
-        *
-        * For now, just disable WEP hwaccel for broadcast when there is
-        * possibility of conflict with default keys. This can maybe later be
-        * optimized by using non-default keys (at least with Atheros ar521x).
-        */
-       if (!sta && alg == ALG_WEP && !local->default_wep_only &&
-           sdata->type != IEEE80211_IF_TYPE_IBSS &&
-           sdata->type != IEEE80211_IF_TYPE_AP) {
-               try_hwaccel = 0;
-       }
-
-       if (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) {
-               /* Software encryption cannot be used with devices that hide
-                * encryption from the host system, so always try to use
-                * hardware acceleration with such devices. */
-               try_hwaccel = 1;
-       }
-
-       if ((local->hw.flags & IEEE80211_HW_NO_TKIP_WMM_HWACCEL) &&
-           alg == ALG_TKIP) {
-               if (sta && (sta->flags & WLAN_STA_WME)) {
-               /* Hardware does not support hwaccel with TKIP when using WMM.
-                */
-                       try_hwaccel = 0;
-               }
-               else if (sdata->type == IEEE80211_IF_TYPE_STA) {
-                       sta = sta_info_get(local, sdata->u.sta.bssid);
-                       if (sta) {
-                               if (sta->flags & WLAN_STA_WME) {
-                                       try_hwaccel = 0;
-                               }
-                               sta_info_put(sta);
-                               sta = NULL;
-                       }
-               }
-       }
-
        if (alg == ALG_NONE) {
-               keyconf = NULL;
-               if (try_hwaccel && key &&
-                   key->hw_key_idx != HW_KEY_IDX_INVALID &&
-                   local->ops->set_key &&
-                   (keyconf = ieee80211_key_data2conf(local, key)) != NULL &&
-                   local->ops->set_key(local_to_hw(local), DISABLE_KEY,
-                                      sta_addr, keyconf, sta ? sta->aid : 0)) {
-                       printk(KERN_DEBUG "%s: set_encrypt - low-level disable"
-                              " failed\n", dev->name);
-                       ret = -EINVAL;
-               }
-               kfree(keyconf);
-
-               if (set_tx_key || sdata->default_key == key) {
-                       ieee80211_debugfs_key_remove_default(sdata);
-                       sdata->default_key = NULL;
-               }
-               ieee80211_debugfs_key_remove(key);
-               if (sta)
-                       sta->key = NULL;
-               else
-                       sdata->keys[idx] = NULL;
                ieee80211_key_free(key);
                key = NULL;
        } else {
-               old_key = key;
-               key = ieee80211_key_alloc(sta ? NULL : sdata, idx, key_len,
-                                         GFP_KERNEL);
+               /*
+                * Need to free it before allocating a new one with
+                * with the same index or the ordering to the driver's
+                * set_key() callback becomes confused.
+                */
+               ieee80211_key_free(key);
+               key = ieee80211_key_alloc(sdata, sta, alg, idx, key_len, _key);
                if (!key) {
                        ret = -ENOMEM;
                        goto err_out;
                }
-
-               /* default to sw encryption; low-level driver sets these if the
-                * requested encryption is supported */
-               key->hw_key_idx = HW_KEY_IDX_INVALID;
-               key->force_sw_encrypt = 1;
-
-               key->alg = alg;
-               key->keyidx = idx;
-               key->keylen = key_len;
-               memcpy(key->key, _key, key_len);
-               if (set_tx_key)
-                       key->default_tx_key = 1;
-
-               if (alg == ALG_CCMP) {
-                       /* Initialize AES key state here as an optimization
-                        * so that it does not need to be initialized for every
-                        * packet. */
-                       key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
-                               key->key);
-                       if (!key->u.ccmp.tfm) {
-                               ret = -ENOMEM;
-                               goto err_free;
-                       }
-               }
-
-               if (set_tx_key || sdata->default_key == old_key) {
-                       ieee80211_debugfs_key_remove_default(sdata);
-                       sdata->default_key = NULL;
-               }
-               ieee80211_debugfs_key_remove(old_key);
-               if (sta)
-                       sta->key = key;
-               else
-                       sdata->keys[idx] = key;
-               ieee80211_key_free(old_key);
-               ieee80211_debugfs_key_add(local, key);
-               if (sta)
-                       ieee80211_debugfs_key_sta_link(key, sta);
-
-               if (try_hwaccel &&
-                   (alg == ALG_WEP || alg == ALG_TKIP || alg == ALG_CCMP))
-                       ieee80211_set_hw_encryption(dev, sta, sta_addr, key);
        }
 
-       if (set_tx_key || (!sta && !sdata->default_key && key)) {
-               sdata->default_key = key;
-               if (key)
-                       ieee80211_debugfs_key_add_default(sdata);
-
-               if (local->ops->set_key_idx &&
-                   local->ops->set_key_idx(local_to_hw(local), idx))
-                       printk(KERN_DEBUG "%s: failed to set TX key idx for "
-                              "low-level driver\n", dev->name);
-       }
+       if (set_tx_key || (!sta && !sdata->default_key && key))
+               ieee80211_set_default_key(sdata, idx);
 
-       if (sta)
-               sta_info_put(sta);
-
-       return 0;
-
-err_free:
-       ieee80211_key_free(key);
-err_out:
+       ret = 0;
+ err_out:
        if (sta)
                sta_info_put(sta);
        return ret;
@@ -270,7 +111,7 @@ static int ieee80211_ioctl_siwgenie(struct net_device *dev,
                int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length);
                if (ret)
                        return ret;
-               sdata->u.sta.auto_bssid_sel = 0;
+               sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
                ieee80211_sta_req_auth(dev, &sdata->u.sta);
                return 0;
        }
@@ -287,16 +128,6 @@ static int ieee80211_ioctl_siwgenie(struct net_device *dev,
        return -EOPNOTSUPP;
 }
 
-static int ieee80211_ioctl_set_radio_enabled(struct net_device *dev,
-                                            int val)
-{
-       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
-       struct ieee80211_conf *conf = &local->hw.conf;
-
-       conf->radio_enabled = val;
-       return ieee80211_hw_config(wdev_priv(dev->ieee80211_ptr));
-}
-
 static int ieee80211_ioctl_giwname(struct net_device *dev,
                                   struct iw_request_info *info,
                                   char *name, char *extra)
@@ -512,13 +343,14 @@ static int ieee80211_ioctl_siwfreq(struct net_device *dev,
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
        if (sdata->type == IEEE80211_IF_TYPE_STA)
-               sdata->u.sta.auto_channel_sel = 0;
+               sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL;
 
        /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
        if (freq->e == 0) {
                if (freq->m < 0) {
                        if (sdata->type == IEEE80211_IF_TYPE_STA)
-                               sdata->u.sta.auto_channel_sel = 1;
+                               sdata->u.sta.flags |=
+                                       IEEE80211_STA_AUTO_CHANNEL_SEL;
                        return 0;
                } else
                        return ieee80211_set_channel(local, freq->m, -1);
@@ -573,7 +405,10 @@ static int ieee80211_ioctl_siwessid(struct net_device *dev,
                        sdata->u.sta.ssid_len = len;
                        return 0;
                }
-               sdata->u.sta.auto_ssid_sel = !data->flags;
+               if (data->flags)
+                       sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
+               else
+                       sdata->u.sta.flags |= IEEE80211_STA_AUTO_SSID_SEL;
                ret = ieee80211_sta_set_ssid(dev, ssid, len);
                if (ret)
                        return ret;
@@ -640,13 +475,13 @@ static int ieee80211_ioctl_siwap(struct net_device *dev,
                               ETH_ALEN);
                        return 0;
                }
-               if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) {
-                       sdata->u.sta.auto_bssid_sel = 1;
-                       sdata->u.sta.auto_channel_sel = 1;
-               else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
-                       sdata->u.sta.auto_bssid_sel = 1;
+               if (is_zero_ether_addr((u8 *) &ap_addr->sa_data))
+                       sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL |
+                               IEEE80211_STA_AUTO_CHANNEL_SEL;
+               else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
+                       sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL;
                else
-                       sdata->u.sta.auto_bssid_sel = 0;
+                       sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
                ret = ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data);
                if (ret)
                        return ret;
@@ -798,6 +633,20 @@ static int ieee80211_ioctl_giwrate(struct net_device *dev,
        return 0;
 }
 
+static int ieee80211_ioctl_giwtxpower(struct net_device *dev,
+                                  struct iw_request_info *info,
+                                  union iwreq_data *data, char *extra)
+{
+       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+
+       data->txpower.fixed = 1;
+       data->txpower.disabled = !(local->hw.conf.radio_enabled);
+       data->txpower.value = local->hw.conf.power_level;
+       data->txpower.flags = IW_TXPOW_DBM;
+
+       return 0;
+}
+
 static int ieee80211_ioctl_siwrts(struct net_device *dev,
                                  struct iw_request_info *info,
                                  struct iw_param *rts, char *extra)
@@ -930,101 +779,6 @@ static int ieee80211_ioctl_giwretry(struct net_device *dev,
        return 0;
 }
 
-static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local,
-                                        struct ieee80211_key *key)
-{
-       struct ieee80211_key_conf *keyconf;
-       u8 addr[ETH_ALEN];
-
-       if (!key || key->alg != ALG_WEP || !key->force_sw_encrypt ||
-           (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
-               return;
-
-       memset(addr, 0xff, ETH_ALEN);
-       keyconf = ieee80211_key_data2conf(local, key);
-       if (keyconf && local->ops->set_key &&
-           local->ops->set_key(local_to_hw(local),
-                              SET_KEY, addr, keyconf, 0) == 0) {
-               key->force_sw_encrypt =
-                       !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
-               key->hw_key_idx = keyconf->hw_key_idx;
-       }
-       kfree(keyconf);
-}
-
-
-static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local,
-                                         struct ieee80211_key *key)
-{
-       struct ieee80211_key_conf *keyconf;
-       u8 addr[ETH_ALEN];
-
-       if (!key || key->alg != ALG_WEP || key->force_sw_encrypt ||
-           (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
-               return;
-
-       memset(addr, 0xff, ETH_ALEN);
-       keyconf = ieee80211_key_data2conf(local, key);
-       if (keyconf && local->ops->set_key)
-               local->ops->set_key(local_to_hw(local), DISABLE_KEY,
-                                  addr, keyconf, 0);
-       kfree(keyconf);
-       key->force_sw_encrypt = 1;
-}
-
-
-static int ieee80211_ioctl_default_wep_only(struct ieee80211_local *local,
-                                           int value)
-{
-       int i;
-       struct ieee80211_sub_if_data *sdata;
-
-       local->default_wep_only = value;
-       read_lock(&local->sub_if_lock);
-       list_for_each_entry(sdata, &local->sub_if_list, list)
-               for (i = 0; i < NUM_DEFAULT_KEYS; i++)
-                       if (value)
-                               ieee80211_key_enable_hwaccel(local,
-                                                            sdata->keys[i]);
-                       else
-                               ieee80211_key_disable_hwaccel(local,
-                                                             sdata->keys[i]);
-       read_unlock(&local->sub_if_lock);
-
-       return 0;
-}
-
-
-void ieee80211_update_default_wep_only(struct ieee80211_local *local)
-{
-       int i = 0;
-       struct ieee80211_sub_if_data *sdata;
-
-       read_lock(&local->sub_if_lock);
-       list_for_each_entry(sdata, &local->sub_if_list, list) {
-
-               if (sdata->dev == local->mdev)
-                       continue;
-
-               /* If there is an AP interface then depend on userspace to
-                  set default_wep_only correctly. */
-               if (sdata->type == IEEE80211_IF_TYPE_AP) {
-                       read_unlock(&local->sub_if_lock);
-                       return;
-               }
-
-               i++;
-       }
-
-       read_unlock(&local->sub_if_lock);
-
-       if (i <= 1)
-               ieee80211_ioctl_default_wep_only(local, 1);
-       else
-               ieee80211_ioctl_default_wep_only(local, 0);
-}
-
-
 static int ieee80211_ioctl_prism2_param(struct net_device *dev,
                                        struct iw_request_info *info,
                                        void *wrqu, char *extra)
@@ -1054,25 +808,31 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev,
                break;
 
        case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
-               if (sdata->type != IEEE80211_IF_TYPE_AP)
+               if (sdata->type == IEEE80211_IF_TYPE_AP) {
+                       if (value)
+                               sdata->flags |= IEEE80211_SDATA_USE_PROTECTION;
+                       else
+                               sdata->flags &= ~IEEE80211_SDATA_USE_PROTECTION;
+                       ieee80211_erp_info_change_notify(dev,
+                                       IEEE80211_ERP_CHANGE_PROTECTION);
+               } else {
                        ret = -ENOENT;
-               else
-                       sdata->use_protection = value;
+               }
                break;
 
        case PRISM2_PARAM_PREAMBLE:
-               local->short_preamble = value;
-               break;
-
-       case PRISM2_PARAM_STAT_TIME:
-               if (!local->stat_time && value) {
-                       local->stat_timer.expires = jiffies + HZ * value / 100;
-                       add_timer(&local->stat_timer);
-               } else if (local->stat_time && !value) {
-                       del_timer_sync(&local->stat_timer);
+               if (sdata->type == IEEE80211_IF_TYPE_AP) {
+                       if (value)
+                               sdata->flags |= IEEE80211_SDATA_SHORT_PREAMBLE;
+                       else
+                               sdata->flags &= ~IEEE80211_SDATA_SHORT_PREAMBLE;
+                       ieee80211_erp_info_change_notify(dev,
+                                       IEEE80211_ERP_CHANGE_PREAMBLE);
+               } else {
+                       ret = -ENOENT;
                }
-               local->stat_time = value;
                break;
+
        case PRISM2_PARAM_SHORT_SLOT_TIME:
                if (value)
                        local->hw.conf.flags |= IEEE80211_CONF_SHORT_SLOT_TIME;
@@ -1086,35 +846,10 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev,
                local->next_mode = value;
                break;
 
-       case PRISM2_PARAM_RADIO_ENABLED:
-               ret = ieee80211_ioctl_set_radio_enabled(dev, value);
-               break;
-
-       case PRISM2_PARAM_ANTENNA_MODE:
-               local->hw.conf.antenna_mode = value;
-               if (ieee80211_hw_config(local))
-                       ret = -EINVAL;
-               break;
-
-       case PRISM2_PARAM_STA_ANTENNA_SEL:
-               local->sta_antenna_sel = value;
-               break;
-
-       case PRISM2_PARAM_TX_POWER_REDUCTION:
-               if (value < 0)
-                       ret = -EINVAL;
-               else
-                       local->hw.conf.tx_power_reduction = value;
-               break;
-
        case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
                local->key_tx_rx_threshold = value;
                break;
 
-       case PRISM2_PARAM_DEFAULT_WEP_ONLY:
-               ret = ieee80211_ioctl_default_wep_only(local, value);
-               break;
-
        case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
                local->wifi_wme_noack_test = value;
                break;
@@ -1127,8 +862,12 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev,
                if (sdata->type != IEEE80211_IF_TYPE_STA &&
                    sdata->type != IEEE80211_IF_TYPE_IBSS)
                        ret = -EINVAL;
-               else
-                       sdata->u.sta.mixed_cell = !!value;
+               else {
+                       if (value)
+                               sdata->u.sta.flags |= IEEE80211_STA_MIXED_CELL;
+                       else
+                               sdata->u.sta.flags &= ~IEEE80211_STA_MIXED_CELL;
+               }
                break;
 
        case PRISM2_PARAM_HW_MODES:
@@ -1138,21 +877,23 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev,
        case PRISM2_PARAM_CREATE_IBSS:
                if (sdata->type != IEEE80211_IF_TYPE_IBSS)
                        ret = -EINVAL;
-               else
-                       sdata->u.sta.create_ibss = !!value;
+               else {
+                       if (value)
+                               sdata->u.sta.flags |= IEEE80211_STA_CREATE_IBSS;
+                       else
+                               sdata->u.sta.flags &= ~IEEE80211_STA_CREATE_IBSS;
+               }
                break;
        case PRISM2_PARAM_WMM_ENABLED:
                if (sdata->type != IEEE80211_IF_TYPE_STA &&
                    sdata->type != IEEE80211_IF_TYPE_IBSS)
                        ret = -EINVAL;
-               else
-                       sdata->u.sta.wmm_enabled = !!value;
-               break;
-       case PRISM2_PARAM_RADAR_DETECT:
-               local->hw.conf.radar_detect = value;
-               break;
-       case PRISM2_PARAM_SPECTRUM_MGMT:
-               local->hw.conf.spect_mgmt = value;
+               else {
+                       if (value)
+                               sdata->u.sta.flags |= IEEE80211_STA_WMM_ENABLED;
+                       else
+                               sdata->u.sta.flags &= ~IEEE80211_STA_WMM_ENABLED;
+               }
                break;
        default:
                ret = -EOPNOTSUPP;
@@ -1180,16 +921,13 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
                break;
 
        case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
-               *param = sdata->use_protection;
+               *param = !!(sdata->flags & IEEE80211_SDATA_USE_PROTECTION);
                break;
 
        case PRISM2_PARAM_PREAMBLE:
-               *param = local->short_preamble;
+               *param = !!(sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE);
                break;
 
-       case PRISM2_PARAM_STAT_TIME:
-               *param = local->stat_time;
-               break;
        case PRISM2_PARAM_SHORT_SLOT_TIME:
                *param = !!(local->hw.conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME);
                break;
@@ -1198,26 +936,10 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
                *param = local->next_mode;
                break;
 
-       case PRISM2_PARAM_ANTENNA_MODE:
-               *param = local->hw.conf.antenna_mode;
-               break;
-
-       case PRISM2_PARAM_STA_ANTENNA_SEL:
-               *param = local->sta_antenna_sel;
-               break;
-
-       case PRISM2_PARAM_TX_POWER_REDUCTION:
-               *param = local->hw.conf.tx_power_reduction;
-               break;
-
        case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
                *param = local->key_tx_rx_threshold;
                break;
 
-       case PRISM2_PARAM_DEFAULT_WEP_ONLY:
-               *param = local->default_wep_only;
-               break;
-
        case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
                *param = local->wifi_wme_noack_test;
                break;
@@ -1234,7 +956,8 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
                if (sdata->type != IEEE80211_IF_TYPE_IBSS)
                        ret = -EINVAL;
                else
-                       *param = !!sdata->u.sta.create_ibss;
+                       *param = !!(sdata->u.sta.flags &
+                                       IEEE80211_STA_CREATE_IBSS);
                break;
 
        case PRISM2_PARAM_MIXED_CELL:
@@ -1242,14 +965,17 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
                    sdata->type != IEEE80211_IF_TYPE_IBSS)
                        ret = -EINVAL;
                else
-                       *param = !!sdata->u.sta.mixed_cell;
+                       *param = !!(sdata->u.sta.flags &
+                                       IEEE80211_STA_MIXED_CELL);
                break;
+
        case PRISM2_PARAM_WMM_ENABLED:
                if (sdata->type != IEEE80211_IF_TYPE_STA &&
                    sdata->type != IEEE80211_IF_TYPE_IBSS)
                        ret = -EINVAL;
                else
-                       *param = !!sdata->u.sta.wmm_enabled;
+                       *param = !!(sdata->u.sta.flags &
+                                       IEEE80211_STA_WMM_ENABLED);
                break;
        default:
                ret = -EOPNOTSUPP;
@@ -1312,12 +1038,7 @@ static int ieee80211_ioctl_siwencode(struct net_device *dev,
                alg = ALG_NONE;
        else if (erq->length == 0) {
                /* No key data - just set the default TX key index */
-               if (sdata->default_key != sdata->keys[idx]) {
-                       ieee80211_debugfs_key_remove_default(sdata);
-                       sdata->default_key = sdata->keys[idx];
-                       if (sdata->default_key)
-                               ieee80211_debugfs_key_add_default(sdata);
-               }
+               ieee80211_set_default_key(sdata, idx);
                return 0;
        }
 
@@ -1362,9 +1083,9 @@ static int ieee80211_ioctl_giwencode(struct net_device *dev,
                return 0;
        }
 
-       memcpy(key, sdata->keys[idx]->key,
-              min((int)erq->length, sdata->keys[idx]->keylen));
-       erq->length = sdata->keys[idx]->keylen;
+       memcpy(key, sdata->keys[idx]->conf.key,
+              min_t(int, erq->length, sdata->keys[idx]->conf.keylen));
+       erq->length = sdata->keys[idx]->conf.keylen;
        erq->flags |= IW_ENCODE_ENABLED;
 
        return 0;
@@ -1390,22 +1111,12 @@ static int ieee80211_ioctl_siwauth(struct net_device *dev,
                        ret = -EINVAL;
                else {
                        /*
-                        * TODO: sdata->u.sta.key_mgmt does not match with WE18
-                        * value completely; could consider modifying this to
-                        * be closer to WE18. For now, this value is not really
-                        * used for anything else than Privacy matching, so the
-                        * current code here should be more or less OK.
+                        * Key management was set by wpa_supplicant,
+                        * we only need this to associate to a network
+                        * that has privacy enabled regardless of not
+                        * having a key.
                         */
-                       if (data->value & IW_AUTH_KEY_MGMT_802_1X) {
-                               sdata->u.sta.key_mgmt =
-                                       IEEE80211_KEY_MGMT_WPA_EAP;
-                       } else if (data->value & IW_AUTH_KEY_MGMT_PSK) {
-                               sdata->u.sta.key_mgmt =
-                                       IEEE80211_KEY_MGMT_WPA_PSK;
-                       } else {
-                               sdata->u.sta.key_mgmt =
-                                       IEEE80211_KEY_MGMT_NONE;
-                       }
+                       sdata->u.sta.key_management_enabled = !!data->value;
                }
                break;
        case IW_AUTH_80211_AUTH_ALG:
@@ -1580,7 +1291,7 @@ static const iw_handler ieee80211_handler[] =
        (iw_handler) ieee80211_ioctl_siwfrag,           /* SIOCSIWFRAG */
        (iw_handler) ieee80211_ioctl_giwfrag,           /* SIOCGIWFRAG */
        (iw_handler) NULL,                              /* SIOCSIWTXPOW */
-       (iw_handler) NULL,                              /* SIOCGIWTXPOW */
+       (iw_handler) ieee80211_ioctl_giwtxpower,        /* SIOCGIWTXPOW */
        (iw_handler) ieee80211_ioctl_siwretry,          /* SIOCSIWRETRY */
        (iw_handler) ieee80211_ioctl_giwretry,          /* SIOCGIWRETRY */
        (iw_handler) ieee80211_ioctl_siwencode,         /* SIOCSIWENCODE */