mac80211: move STA timer restart
[safe/jmp/linux-2.6] / net / mac80211 / mlme.c
index 25f90f7..809fb91 100644 (file)
@@ -96,20 +96,6 @@ static int ieee80211_compatible_rates(struct ieee80211_sta_bss *bss,
 }
 
 /* frame sending functions */
-void ieee80211_sta_tx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
-                     int encrypt)
-{
-       skb->dev = sdata->local->mdev;
-       skb_set_mac_header(skb, 0);
-       skb_set_network_header(skb, 0);
-       skb_set_transport_header(skb, 0);
-
-       skb->iif = sdata->dev->ifindex;
-       skb->do_not_encrypt = !encrypt;
-
-       dev_queue_xmit(skb);
-}
-
 static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
                                struct ieee80211_if_sta *ifsta,
                                int transaction, u8 *extra, size_t extra_len,
@@ -144,7 +130,7 @@ static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
        if (extra)
                memcpy(skb_put(skb, extra_len), extra, extra_len);
 
-       ieee80211_sta_tx(sdata, skb, encrypt);
+       ieee80211_tx_skb(sdata, skb, encrypt);
 }
 
 void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
@@ -204,7 +190,7 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
                *pos = rate->bitrate / 5;
        }
 
-       ieee80211_sta_tx(sdata, skb, 0);
+       ieee80211_tx_skb(sdata, skb, 0);
 }
 
 static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
@@ -412,7 +398,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
        if (ifsta->assocreq_ies)
                memcpy(ifsta->assocreq_ies, ies, ifsta->assocreq_ies_len);
 
-       ieee80211_sta_tx(sdata, skb, 0);
+       ieee80211_tx_skb(sdata, skb, 0);
 }
 
 
@@ -442,54 +428,7 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
        /* u.deauth.reason_code == u.disassoc.reason_code */
        mgmt->u.deauth.reason_code = cpu_to_le16(reason);
 
-       ieee80211_sta_tx(sdata, skb, 0);
-}
-
-static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata,
-                                       struct ieee80211_msrment_ie *request_ie,
-                                       const u8 *da, const u8 *bssid,
-                                       u8 dialog_token)
-{
-       struct ieee80211_local *local = sdata->local;
-       struct sk_buff *skb;
-       struct ieee80211_mgmt *msr_report;
-
-       skb = dev_alloc_skb(sizeof(*msr_report) + local->hw.extra_tx_headroom +
-                               sizeof(struct ieee80211_msrment_ie));
-
-       if (!skb) {
-               printk(KERN_ERR "%s: failed to allocate buffer for "
-                               "measurement report frame\n", sdata->dev->name);
-               return;
-       }
-
-       skb_reserve(skb, local->hw.extra_tx_headroom);
-       msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24);
-       memset(msr_report, 0, 24);
-       memcpy(msr_report->da, da, ETH_ALEN);
-       memcpy(msr_report->sa, sdata->dev->dev_addr, ETH_ALEN);
-       memcpy(msr_report->bssid, bssid, ETH_ALEN);
-       msr_report->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
-                                               IEEE80211_STYPE_ACTION);
-
-       skb_put(skb, 1 + sizeof(msr_report->u.action.u.measurement));
-       msr_report->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT;
-       msr_report->u.action.u.measurement.action_code =
-                               WLAN_ACTION_SPCT_MSR_RPRT;
-       msr_report->u.action.u.measurement.dialog_token = dialog_token;
-
-       msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT;
-       msr_report->u.action.u.measurement.length =
-                       sizeof(struct ieee80211_msrment_ie);
-
-       memset(&msr_report->u.action.u.measurement.msr_elem, 0,
-               sizeof(struct ieee80211_msrment_ie));
-       msr_report->u.action.u.measurement.msr_elem.token = request_ie->token;
-       msr_report->u.action.u.measurement.msr_elem.mode |=
-                       IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED;
-       msr_report->u.action.u.measurement.msr_elem.type = request_ie->type;
-
-       ieee80211_sta_tx(sdata, skb, 0);
+       ieee80211_tx_skb(sdata, skb, 0);
 }
 
 /* MLME */
@@ -1011,24 +950,6 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
                            elems.challenge_len + 2, 1);
 }
 
-static void ieee80211_sta_process_measurement_req(struct ieee80211_sub_if_data *sdata,
-                                               struct ieee80211_mgmt *mgmt,
-                                               size_t len)
-{
-       /*
-        * Ignoring measurement request is spec violation.
-        * Mandatory measurements must be reported optional
-        * measurements might be refused or reported incapable
-        * For now just refuse
-        * TODO: Answer basic measurement as unmeasured
-        */
-       ieee80211_send_refuse_measurement_request(sdata,
-                       &mgmt->u.action.u.measurement.msr_elem,
-                       mgmt->sa, mgmt->bssid,
-                       mgmt->u.action.u.measurement.dialog_token);
-}
-
-
 static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
                                   struct ieee80211_if_sta *ifsta,
                                   struct ieee80211_mgmt *mgmt,
@@ -1861,7 +1782,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
        printk(KERN_DEBUG "%s: Sending ProbeResp to %s\n",
               sdata->dev->name, print_mac(mac, resp->da));
 #endif /* CONFIG_MAC80211_IBSS_DEBUG */
-       ieee80211_sta_tx(sdata, skb, 0);
+       ieee80211_tx_skb(sdata, skb, 0);
 }
 
 static void ieee80211_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
@@ -1870,32 +1791,16 @@ static void ieee80211_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
                                     size_t len,
                                     struct ieee80211_rx_status *rx_status)
 {
-       struct ieee80211_local *local = sdata->local;
-
-       /* all categories we currently handle have action_code */
-       if (len < IEEE80211_MIN_ACTION_SIZE + 1)
+       /* currently we only handle mesh interface action frames here */
+       if (!ieee80211_vif_is_mesh(&sdata->vif))
                return;
 
        switch (mgmt->u.action.category) {
-       case WLAN_CATEGORY_SPECTRUM_MGMT:
-               if (local->hw.conf.channel->band != IEEE80211_BAND_5GHZ)
-                       break;
-               switch (mgmt->u.action.u.measurement.action_code) {
-               case WLAN_ACTION_SPCT_MSR_REQ:
-                       if (len < (IEEE80211_MIN_ACTION_SIZE +
-                                  sizeof(mgmt->u.action.u.measurement)))
-                               break;
-                       ieee80211_sta_process_measurement_req(sdata, mgmt, len);
-                       break;
-               }
-               break;
        case PLINK_CATEGORY:
-               if (ieee80211_vif_is_mesh(&sdata->vif))
-                       mesh_rx_plink_frame(sdata, mgmt, len, rx_status);
+               mesh_rx_plink_frame(sdata, mgmt, len, rx_status);
                break;
        case MESH_PATH_SEL_CATEGORY:
-               if (ieee80211_vif_is_mesh(&sdata->vif))
-                       mesh_rx_path_sel_frame(sdata, mgmt, len);
+               mesh_rx_path_sel_frame(sdata, mgmt, len);
                break;
        }
 }
@@ -2008,32 +1913,6 @@ static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata)
 }
 
 
-static void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, unsigned long exp_time)
-{
-       struct ieee80211_local *local = sdata->local;
-       struct sta_info *sta, *tmp;
-       LIST_HEAD(tmp_list);
-       DECLARE_MAC_BUF(mac);
-       unsigned long flags;
-
-       spin_lock_irqsave(&local->sta_lock, flags);
-       list_for_each_entry_safe(sta, tmp, &local->sta_list, list)
-               if (time_after(jiffies, sta->last_rx + exp_time)) {
-#ifdef CONFIG_MAC80211_IBSS_DEBUG
-                       printk(KERN_DEBUG "%s: expiring inactive STA %s\n",
-                              sdata->dev->name, print_mac(mac, sta->addr));
-#endif
-                       __sta_info_unlink(&sta);
-                       if (sta)
-                               list_add(&sta->list, &tmp_list);
-               }
-       spin_unlock_irqrestore(&local->sta_lock, flags);
-
-       list_for_each_entry_safe(sta, tmp, &tmp_list, list)
-               sta_info_destroy(sta);
-}
-
-
 static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata,
                                     struct ieee80211_if_sta *ifsta)
 {
@@ -2715,6 +2594,13 @@ void ieee80211_sta_work(struct work_struct *work)
        }
 }
 
+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_mlme_notify_scan_completed(struct ieee80211_local *local)
 {
        struct ieee80211_sub_if_data *sdata = local->scan_sdata;
@@ -2727,4 +2613,10 @@ void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
                    !ieee80211_sta_active_ibss(sdata)))
                        ieee80211_sta_find_ibss(sdata, ifsta);
        }
+
+       /* Restart STA timers */
+       rcu_read_lock();
+       list_for_each_entry_rcu(sdata, &local->interfaces, list)
+               ieee80211_restart_sta_timer(sdata);
+       rcu_read_unlock();
 }