]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/mac80211/mlme.c
wireless: move mesh config length constant
[linux-2.6-omap-h63xx.git] / net / mac80211 / mlme.c
index 829995e740a78fdccb673586312e2bdbb4124962..9e6c75abc92200bdad6b216bb18d54f8e39d7b39 100644 (file)
@@ -236,7 +236,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_local *local = sdata->local;
        struct sk_buff *skb;
        struct ieee80211_mgmt *mgmt;
-       u8 *pos, *ies, *ht_add_ie;
+       u8 *pos, *ies, *ht_ie;
        int i, len, count, rates_len, supp_rates_len;
        u16 capab;
        struct ieee80211_bss *bss;
@@ -393,24 +393,25 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
 
        /* wmm support is a must to HT */
        if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) &&
-           sband->ht_info.ht_supported &&
-           (ht_add_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_EXTRA_INFO))) {
-               struct ieee80211_ht_addt_info *ht_add_info =
-                       (struct ieee80211_ht_addt_info *)ht_add_ie;
-               u16 cap = sband->ht_info.cap;
+           sband->ht_cap.ht_supported &&
+           (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) &&
+           ht_ie[1] >= sizeof(struct ieee80211_ht_info)) {
+               struct ieee80211_ht_info *ht_info =
+                       (struct ieee80211_ht_info *)(ht_ie + 2);
+               u16 cap = sband->ht_cap.cap;
                __le16 tmp;
                u32 flags = local->hw.conf.channel->flags;
 
-               switch (ht_add_info->ht_param & IEEE80211_HT_IE_CHA_SEC_OFFSET) {
-               case IEEE80211_HT_IE_CHA_SEC_ABOVE:
+               switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
+               case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
                        if (flags & IEEE80211_CHAN_NO_FAT_ABOVE) {
-                               cap &= ~IEEE80211_HT_CAP_SUP_WIDTH;
+                               cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
                                cap &= ~IEEE80211_HT_CAP_SGI_40;
                        }
                        break;
-               case IEEE80211_HT_IE_CHA_SEC_BELOW:
+               case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
                        if (flags & IEEE80211_CHAN_NO_FAT_BELOW) {
-                               cap &= ~IEEE80211_HT_CAP_SUP_WIDTH;
+                               cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
                                cap &= ~IEEE80211_HT_CAP_SGI_40;
                        }
                        break;
@@ -424,9 +425,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
                memcpy(pos, &tmp, sizeof(u16));
                pos += sizeof(u16);
                /* TODO: needs a define here for << 2 */
-               *pos++ = sband->ht_info.ampdu_factor |
-                        (sband->ht_info.ampdu_density << 2);
-               memcpy(pos, sband->ht_info.supp_mcs_set, 16);
+               *pos++ = sband->ht_cap.ampdu_factor |
+                        (sband->ht_cap.ampdu_density << 2);
+               memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs));
        }
 
        kfree(ifsta->assocreq_ies);
@@ -571,7 +572,7 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
 static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
                                           u16 capab, bool erp_valid, u8 erp)
 {
-       struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf;
+       struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
        struct ieee80211_if_sta *ifsta = &sdata->u.sta;
 #endif
@@ -699,14 +700,15 @@ static void ieee80211_sta_send_associnfo(struct ieee80211_sub_if_data *sdata,
 
 
 static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
-                                    struct ieee80211_if_sta *ifsta)
+                                    struct ieee80211_if_sta *ifsta,
+                                    u32 bss_info_changed)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_conf *conf = &local_to_hw(local)->conf;
-       u32 changed = BSS_CHANGED_ASSOC;
 
        struct ieee80211_bss *bss;
 
+       bss_info_changed |= BSS_CHANGED_ASSOC;
        ifsta->flags |= IEEE80211_STA_ASSOCIATED;
 
        if (sdata->vif.type != NL80211_IFTYPE_STATION)
@@ -717,23 +719,16 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
                                   ifsta->ssid, ifsta->ssid_len);
        if (bss) {
                /* set timing information */
-               sdata->bss_conf.beacon_int = bss->beacon_int;
-               sdata->bss_conf.timestamp = bss->timestamp;
-               sdata->bss_conf.dtim_period = bss->dtim_period;
+               sdata->vif.bss_conf.beacon_int = bss->beacon_int;
+               sdata->vif.bss_conf.timestamp = bss->timestamp;
+               sdata->vif.bss_conf.dtim_period = bss->dtim_period;
 
-               changed |= ieee80211_handle_bss_capability(sdata,
+               bss_info_changed |= ieee80211_handle_bss_capability(sdata,
                        bss->capability, bss->has_erp_value, bss->erp_value);
 
                ieee80211_rx_bss_put(local, bss);
        }
 
-       if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
-               changed |= BSS_CHANGED_HT;
-               sdata->bss_conf.assoc_ht = 1;
-               sdata->bss_conf.ht_conf = &conf->ht_conf;
-               sdata->bss_conf.ht_bss_conf = &conf->ht_bss_conf;
-       }
-
        ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET;
        memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN);
        ieee80211_sta_send_associnfo(sdata, ifsta);
@@ -741,14 +736,14 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
        ifsta->last_probe = jiffies;
        ieee80211_led_assoc(local, 1);
 
-       sdata->bss_conf.assoc = 1;
+       sdata->vif.bss_conf.assoc = 1;
        /*
         * For now just always ask the driver to update the basic rateset
         * when we have associated, we aren't checking whether it actually
         * changed or not.
         */
-       changed |= BSS_CHANGED_BASIC_RATES;
-       ieee80211_bss_info_change_notify(sdata, changed);
+       bss_info_changed |= BSS_CHANGED_BASIC_RATES;
+       ieee80211_bss_info_change_notify(sdata, bss_info_changed);
 
        netif_tx_start_all_queues(sdata->dev);
        netif_carrier_on(sdata->dev);
@@ -764,6 +759,7 @@ static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
                printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n",
                       sdata->dev->name, ifsta->bssid);
                ifsta->state = IEEE80211_STA_MLME_DISABLED;
+               ieee80211_sta_send_apinfo(sdata, ifsta);
                return;
        }
 
@@ -794,6 +790,7 @@ static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
                       " timed out\n",
                       sdata->dev->name, ifsta->bssid);
                ifsta->state = IEEE80211_STA_MLME_DISABLED;
+               ieee80211_sta_send_apinfo(sdata, ifsta);
                return;
        }
 
@@ -812,7 +809,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
 {
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
-       u32 changed = BSS_CHANGED_ASSOC;
+       u32 changed = 0;
 
        rcu_read_lock();
 
@@ -846,15 +843,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
        ifsta->flags &= ~IEEE80211_STA_ASSOCIATED;
        changed |= ieee80211_reset_erp_info(sdata);
 
-       if (sdata->bss_conf.assoc_ht)
-               changed |= BSS_CHANGED_HT;
-
-       sdata->bss_conf.assoc_ht = 0;
-       sdata->bss_conf.ht_conf = NULL;
-       sdata->bss_conf.ht_bss_conf = NULL;
-
        ieee80211_led_assoc(local, 0);
-       sdata->bss_conf.assoc = 0;
+       changed |= BSS_CHANGED_ASSOC;
+       sdata->vif.bss_conf.assoc = false;
 
        ieee80211_sta_send_apinfo(sdata, ifsta);
 
@@ -866,6 +857,11 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
        rcu_read_unlock();
 
        sta_info_destroy(sta);
+
+       local->hw.conf.ht.enabled = false;
+       ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_HT);
+
+       ieee80211_bss_info_change_notify(sdata, changed);
 }
 
 static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata)
@@ -915,6 +911,7 @@ static void ieee80211_associate(struct ieee80211_sub_if_data *sdata,
                       " timed out\n",
                       sdata->dev->name, ifsta->bssid);
                ifsta->state = IEEE80211_STA_MLME_DISABLED;
+               ieee80211_sta_send_apinfo(sdata, ifsta);
                return;
        }
 
@@ -1126,7 +1123,8 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
        reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
 
        if (ifsta->flags & IEEE80211_STA_AUTHENTICATED)
-               printk(KERN_DEBUG "%s: deauthenticated\n", sdata->dev->name);
+               printk(KERN_DEBUG "%s: deauthenticated (Reason: %u)\n",
+                               sdata->dev->name, reason_code);
 
        if (ifsta->state == IEEE80211_STA_MLME_AUTHENTICATE ||
            ifsta->state == IEEE80211_STA_MLME_ASSOCIATE ||
@@ -1157,7 +1155,8 @@ static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
        reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
 
        if (ifsta->flags & IEEE80211_STA_ASSOCIATED)
-               printk(KERN_DEBUG "%s: disassociated\n", sdata->dev->name);
+               printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n",
+                               sdata->dev->name, reason_code);
 
        if (ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) {
                ifsta->state = IEEE80211_STA_MLME_ASSOCIATE;
@@ -1181,10 +1180,12 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        u64 rates, basic_rates;
        u16 capab_info, status_code, aid;
        struct ieee802_11_elems elems;
-       struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf;
+       struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
        u8 *pos;
+       u32 changed = 0;
        int i, j;
-       bool have_higher_than_11mbit = false;
+       bool have_higher_than_11mbit = false, newsta = false;
+       u16 ap_ht_cap_flags;
 
        /* AssocResp and ReassocResp have identical structure, so process both
         * of them in this function. */
@@ -1247,7 +1248,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        sta = sta_info_get(local, ifsta->bssid);
        if (!sta) {
                struct ieee80211_bss *bss;
-               int err;
+
+               newsta = true;
 
                sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC);
                if (!sta) {
@@ -1266,13 +1268,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
                        ieee80211_rx_bss_put(local, bss);
                }
 
-               err = sta_info_insert(sta);
-               if (err) {
-                       printk(KERN_DEBUG "%s: failed to insert STA entry for"
-                              " the AP (error %d)\n", sdata->dev->name, err);
-                       rcu_read_unlock();
-                       return;
-               }
                /* update new sta with its last rx activity */
                sta->last_rx = jiffies;
        }
@@ -1323,7 +1318,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        }
 
        sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
-       sdata->bss_conf.basic_rates = basic_rates;
+       sdata->vif.bss_conf.basic_rates = basic_rates;
 
        /* cf. IEEE 802.11 9.2.12 */
        if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
@@ -1332,31 +1327,43 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        else
                sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
 
-       if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param &&
-           (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) {
-               struct ieee80211_ht_bss_info bss_info;
-               ieee80211_ht_cap_ie_to_ht_info(
-                               elems.ht_cap_elem, &sta->sta.ht_info);
-               ieee80211_ht_addt_info_ie_to_ht_bss_info(
-                               elems.ht_info_elem, &bss_info);
-               ieee80211_handle_ht(local, 1, &sta->sta.ht_info, &bss_info);
-       }
+       if (elems.ht_cap_elem)
+               ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
+                               elems.ht_cap_elem, &sta->sta.ht_cap);
+
+       ap_ht_cap_flags = sta->sta.ht_cap.cap;
 
        rate_control_rate_init(sta);
 
-       if (elems.wmm_param) {
+       if (elems.wmm_param)
                set_sta_flags(sta, WLAN_STA_WME);
-               rcu_read_unlock();
+
+       if (newsta) {
+               int err = sta_info_insert(sta);
+               if (err) {
+                       printk(KERN_DEBUG "%s: failed to insert STA entry for"
+                              " the AP (error %d)\n", sdata->dev->name, err);
+                       rcu_read_unlock();
+                       return;
+               }
+       }
+
+       rcu_read_unlock();
+
+       if (elems.wmm_param)
                ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param,
                                         elems.wmm_param_len);
-       } else
-               rcu_read_unlock();
+
+       if (elems.ht_info_elem && elems.wmm_param &&
+           (ifsta->flags & IEEE80211_STA_WMM_ENABLED))
+               changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
+                                              ap_ht_cap_flags);
 
        /* set AID and assoc capability,
         * ieee80211_set_associated() will tell the driver */
        bss_conf->aid = aid;
        bss_conf->assoc_capability = capab_info;
-       ieee80211_set_associated(sdata, ifsta);
+       ieee80211_set_associated(sdata, ifsta, changed);
 
        ieee80211_associated(sdata, ifsta);
 }
@@ -1374,6 +1381,13 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_supported_band *sband;
        union iwreq_data wrqu;
 
+       skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
+       if (!skb) {
+               printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
+                      "response\n", sdata->dev->name);
+               return -ENOMEM;
+       }
+
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
 
        /* Remove possible STA entries from other IBSS networks. */
@@ -1399,63 +1413,62 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
                return res;
 
        /* Build IBSS probe response */
-       skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
-       if (skb) {
-               skb_reserve(skb, local->hw.extra_tx_headroom);
 
-               mgmt = (struct ieee80211_mgmt *)
-                       skb_put(skb, 24 + sizeof(mgmt->u.beacon));
-               memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
-               mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
-                                                 IEEE80211_STYPE_PROBE_RESP);
-               memset(mgmt->da, 0xff, ETH_ALEN);
-               memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
-               memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
-               mgmt->u.beacon.beacon_int =
-                       cpu_to_le16(local->hw.conf.beacon_int);
-               mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp);
-               mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
-
-               pos = skb_put(skb, 2 + ifsta->ssid_len);
-               *pos++ = WLAN_EID_SSID;
-               *pos++ = ifsta->ssid_len;
-               memcpy(pos, ifsta->ssid, ifsta->ssid_len);
-
-               rates = bss->supp_rates_len;
-               if (rates > 8)
-                       rates = 8;
-               pos = skb_put(skb, 2 + rates);
-               *pos++ = WLAN_EID_SUPP_RATES;
-               *pos++ = rates;
-               memcpy(pos, bss->supp_rates, rates);
+       skb_reserve(skb, local->hw.extra_tx_headroom);
 
-               if (bss->band == IEEE80211_BAND_2GHZ) {
-                       pos = skb_put(skb, 2 + 1);
-                       *pos++ = WLAN_EID_DS_PARAMS;
-                       *pos++ = 1;
-                       *pos++ = ieee80211_frequency_to_channel(bss->freq);
-               }
+       mgmt = (struct ieee80211_mgmt *)
+               skb_put(skb, 24 + sizeof(mgmt->u.beacon));
+       memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
+       mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
+                                               IEEE80211_STYPE_PROBE_RESP);
+       memset(mgmt->da, 0xff, ETH_ALEN);
+       memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
+       memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
+       mgmt->u.beacon.beacon_int =
+               cpu_to_le16(local->hw.conf.beacon_int);
+       mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp);
+       mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
 
-               pos = skb_put(skb, 2 + 2);
-               *pos++ = WLAN_EID_IBSS_PARAMS;
-               *pos++ = 2;
-               /* FIX: set ATIM window based on scan results */
-               *pos++ = 0;
-               *pos++ = 0;
+       pos = skb_put(skb, 2 + ifsta->ssid_len);
+       *pos++ = WLAN_EID_SSID;
+       *pos++ = ifsta->ssid_len;
+       memcpy(pos, ifsta->ssid, ifsta->ssid_len);
 
-               if (bss->supp_rates_len > 8) {
-                       rates = bss->supp_rates_len - 8;
-                       pos = skb_put(skb, 2 + rates);
-                       *pos++ = WLAN_EID_EXT_SUPP_RATES;
-                       *pos++ = rates;
-                       memcpy(pos, &bss->supp_rates[8], rates);
-               }
+       rates = bss->supp_rates_len;
+       if (rates > 8)
+               rates = 8;
+       pos = skb_put(skb, 2 + rates);
+       *pos++ = WLAN_EID_SUPP_RATES;
+       *pos++ = rates;
+       memcpy(pos, bss->supp_rates, rates);
+
+       if (bss->band == IEEE80211_BAND_2GHZ) {
+               pos = skb_put(skb, 2 + 1);
+               *pos++ = WLAN_EID_DS_PARAMS;
+               *pos++ = 1;
+               *pos++ = ieee80211_frequency_to_channel(bss->freq);
+       }
 
-               ifsta->probe_resp = skb;
+       pos = skb_put(skb, 2 + 2);
+       *pos++ = WLAN_EID_IBSS_PARAMS;
+       *pos++ = 2;
+       /* FIX: set ATIM window based on scan results */
+       *pos++ = 0;
+       *pos++ = 0;
 
-               ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+       if (bss->supp_rates_len > 8) {
+               rates = bss->supp_rates_len - 8;
+               pos = skb_put(skb, 2 + rates);
+               *pos++ = WLAN_EID_EXT_SUPP_RATES;
+               *pos++ = rates;
+               memcpy(pos, &bss->supp_rates[8], rates);
        }
 
+       ifsta->probe_resp = skb;
+
+       ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+
+
        rates = 0;
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
        for (i = 0; i < bss->supp_rates_len; i++) {
@@ -1656,7 +1669,6 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
        size_t baselen;
        struct ieee802_11_elems elems;
        struct ieee80211_local *local = sdata->local;
-       struct ieee80211_conf *conf = &local->hw.conf;
        u32 changed = 0;
        bool erp_valid;
        u8 erp_value = 0;
@@ -1692,14 +1704,31 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
                        le16_to_cpu(mgmt->u.beacon.capab_info),
                        erp_valid, erp_value);
 
-       if (elems.ht_cap_elem && elems.ht_info_elem &&
-           elems.wmm_param && conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
-               struct ieee80211_ht_bss_info bss_info;
 
-               ieee80211_ht_addt_info_ie_to_ht_bss_info(
-                               elems.ht_info_elem, &bss_info);
-               changed |= ieee80211_handle_ht(local, 1, &conf->ht_conf,
-                                              &bss_info);
+       if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param) {
+               struct sta_info *sta;
+               struct ieee80211_supported_band *sband;
+               u16 ap_ht_cap_flags;
+
+               rcu_read_lock();
+
+               sta = sta_info_get(local, ifsta->bssid);
+               if (!sta) {
+                       rcu_read_unlock();
+                       return;
+               }
+
+               sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
+
+               ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
+                               elems.ht_cap_elem, &sta->sta.ht_cap);
+
+               ap_ht_cap_flags = sta->sta.ht_cap.cap;
+
+               rcu_read_unlock();
+
+               changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
+                                              ap_ht_cap_flags);
        }
 
        ieee80211_bss_info_change_notify(sdata, changed);