]> err.no Git - linux-2.6/blobdiff - net/mac80211/ieee80211_sta.c
the scheduled ieee80211 softmac removal
[linux-2.6] / net / mac80211 / ieee80211_sta.c
index a3e96eb59eb0ddfea54cef2f6d941a77dd6f0ed5..8b991ebcbb4ed7b682fd1dbad4663d3a6ca3c466 100644 (file)
@@ -1454,7 +1454,7 @@ void sta_addba_resp_timer_expired(unsigned long data)
 {
        /* not an elegant detour, but there is no choice as the timer passes
         * only one argument, and both sta_info and TID are needed, so init
-        * flow in sta_info_add gives the TID as data, while the timer_to_id
+        * flow in sta_info_create gives the TID as data, while the timer_to_id
         * array gives the sta through container_of */
        u16 tid = *(int *)data;
        struct sta_info *temp_sta = container_of((void *)data,
@@ -1505,7 +1505,7 @@ void sta_rx_agg_session_timer_expired(unsigned long data)
 {
        /* not an elegant detour, but there is no choice as the timer passes
         * only one argument, and verious sta_info are needed here, so init
-        * flow in sta_info_add gives the TID as data, while the timer_to_id
+        * flow in sta_info_create gives the TID as data, while the timer_to_id
         * array gives the sta through container_of */
        u8 *ptid = (u8 *)data;
        u8 *timer_to_id = ptid - *ptid;
@@ -1829,11 +1829,12 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        sta = sta_info_get(local, ifsta->bssid);
        if (!sta) {
                struct ieee80211_sta_bss *bss;
+               int err;
 
-               sta = sta_info_add(sdata, ifsta->bssid);
-               if (IS_ERR(sta)) {
-                       printk(KERN_DEBUG "%s: failed to add STA entry for the"
-                              " AP (error %ld)\n", dev->name, PTR_ERR(sta));
+               sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC);
+               if (!sta) {
+                       printk(KERN_DEBUG "%s: failed to alloc STA entry for"
+                              " the AP\n", dev->name);
                        rcu_read_unlock();
                        return;
                }
@@ -1846,8 +1847,27 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
                        sta->last_noise = bss->noise;
                        ieee80211_rx_bss_put(dev, bss);
                }
+
+               err = sta_info_insert(sta);
+               if (err) {
+                       printk(KERN_DEBUG "%s: failed to insert STA entry for"
+                              " the AP (error %d)\n", dev->name, err);
+                       sta_info_destroy(sta);
+                       rcu_read_unlock();
+                       return;
+               }
        }
 
+       /*
+        * FIXME: Do we really need to update the sta_info's information here?
+        *        We already know about the AP (we found it in our list) so it
+        *        should already be filled with the right info, no?
+        *        As is stands, all this is racy because typically we assume
+        *        the information that is filled in here (except flags) doesn't
+        *        change while a STA structure is alive. As such, it should move
+        *        to between the sta_info_alloc() and sta_info_insert() above.
+        */
+
        sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP |
                      WLAN_STA_AUTHORIZED;
 
@@ -1910,16 +1930,16 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
 
        if (elems.wmm_param && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) {
                sta->flags |= WLAN_STA_WME;
+               rcu_read_unlock();
                ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param,
                                         elems.wmm_param_len);
-       }
+       } else
+               rcu_read_unlock();
 
        /* set AID, ieee80211_set_associated() will tell the driver */
        bss_conf->aid = aid;
        ieee80211_set_associated(dev, ifsta, 1);
 
-       rcu_read_unlock();
-
        ieee80211_associated(dev, ifsta);
 }
 
@@ -2588,10 +2608,8 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
                                       "local TSF - IBSS merge with BSSID %s\n",
                                       dev->name, print_mac(mac, mgmt->bssid));
                        ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss);
-                       rcu_read_lock();
                        ieee80211_ibss_add_sta(dev, NULL,
                                               mgmt->bssid, mgmt->sa);
-                       rcu_read_unlock();
                }
        }
 
@@ -3558,6 +3576,13 @@ static void ieee80211_send_nullfunc(struct ieee80211_local *local,
 }
 
 
+static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata)
+{
+       if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+           ieee80211_vif_is_mesh(&sdata->vif))
+               ieee80211_sta_timer((unsigned long)sdata);
+}
+
 void ieee80211_scan_completed(struct ieee80211_hw *hw)
 {
        struct ieee80211_local *local = hw_to_local(hw);
@@ -3571,6 +3596,12 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
 
        if (local->sta_hw_scanning) {
                local->sta_hw_scanning = 0;
+               /* Restart STA timer for HW scan case */
+               rcu_read_lock();
+               list_for_each_entry_rcu(sdata, &local->interfaces, list)
+                       ieee80211_restart_sta_timer(sdata);
+               rcu_read_unlock();
+
                goto done;
        }
 
@@ -3597,14 +3628,12 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
                if (sdata->dev == local->mdev)
                        continue;
 
-               if (sdata->vif.type == IEEE80211_IF_TYPE_STA) {
-                       if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)
-                               ieee80211_send_nullfunc(local, sdata, 0);
-                       ieee80211_sta_timer((unsigned long)sdata);
-               }
+               /* Tell AP we're back */
+               if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
+                   sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)
+                       ieee80211_send_nullfunc(local, sdata, 0);
 
-               if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT)
-                       ieee80211_sta_timer((unsigned long)sdata);
+               ieee80211_restart_sta_timer(sdata);
 
                netif_wake_queue(sdata->dev);
        }
@@ -3860,8 +3889,8 @@ ieee80211_sta_scan_result(struct net_device *dev,
                                                  bss->ssid);
        }
 
-       if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS
-           || bss_mesh_cfg(bss))) {
+       if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)
+           || bss_mesh_cfg(bss)) {
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = SIOCGIWMODE;
                if (bss_mesh_cfg(bss))
@@ -3958,18 +3987,35 @@ ieee80211_sta_scan_result(struct net_device *dev,
        if (bss_mesh_cfg(bss)) {
                char *buf;
                u8 *cfg = bss_mesh_cfg(bss);
-               buf = kmalloc(200, GFP_ATOMIC);
+               buf = kmalloc(50, GFP_ATOMIC);
                if (buf) {
                        memset(&iwe, 0, sizeof(iwe));
                        iwe.cmd = IWEVCUSTOM;
-                       sprintf(buf, "Mesh network (version %d)\n"
-                       "\t\t\tPath Selection Protocol ID: 0x%02X%02X%02X%02X\n"
-                       "\t\t\tPath Selection Metric ID: 0x%02X%02X%02X%02X\n"
-                       "\t\t\tCongestion Control Mode ID: 0x%02X%02X%02X%02X\n"
-                       "\t\t\tChannel Precedence: 0x%02X%02X%02X%02X",
-                       cfg[0], cfg[1], cfg[2], cfg[3], cfg[4], cfg[5], cfg[6],
-                       cfg[7], cfg[8], cfg[9], cfg[10], cfg[11], cfg[12],
-                       cfg[13], cfg[14], cfg[15], cfg[16]);
+                       sprintf(buf, "Mesh network (version %d)", cfg[0]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Path Selection Protocol ID: "
+                               "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3],
+                                                       cfg[4]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Path Selection Metric ID: "
+                               "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7],
+                                                       cfg[8]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Congestion Control Mode ID: "
+                               "0x%02X%02X%02X%02X", cfg[9], cfg[10],
+                                                       cfg[11], cfg[12]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Channel Precedence: "
+                               "0x%02X%02X%02X%02X", cfg[13], cfg[14],
+                                                       cfg[15], cfg[16]);
                        iwe.u.data.length = strlen(buf);
                        current_ev = iwe_stream_add_point(current_ev, end_buf,
                                                          &iwe, buf);
@@ -4023,7 +4069,6 @@ int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len)
 }
 
 
-/* must be called under RCU read lock */
 struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
                                         struct sk_buff *skb, u8 *bssid,
                                         u8 *addr)
@@ -4046,8 +4091,8 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
        printk(KERN_DEBUG "%s: Adding new IBSS station %s (dev=%s)\n",
               wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name);
 
-       sta = sta_info_add(sdata, addr);
-       if (IS_ERR(sta))
+       sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
+       if (!sta)
                return NULL;
 
        sta->flags |= WLAN_STA_AUTHORIZED;
@@ -4057,6 +4102,11 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
 
        rate_control_rate_init(sta, local);
 
+       if (sta_info_insert(sta)) {
+               sta_info_destroy(sta);
+               return NULL;
+       }
+
        return sta;
 }