mac80211: fix addba timer (again...)
[safe/jmp/linux-2.6] / net / mac80211 / mesh_plink.c
index 990a4b7..ffcbad7 100644 (file)
@@ -93,7 +93,7 @@ static inline void mesh_plink_fsm_restart(struct sta_info *sta)
  *       on it in the lifecycle management section!
  */
 static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
-                                        u8 *hw_addr, u64 rates)
+                                        u8 *hw_addr, u32 rates)
 {
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
@@ -106,7 +106,8 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
                return NULL;
 
        sta->flags = WLAN_STA_AUTHORIZED;
-       sta->supp_rates[local->hw.conf.channel->band] = rates;
+       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
+       rate_control_rate_init(sta);
 
        return sta;
 }
@@ -217,11 +218,11 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
                memcpy(pos, &reason, 2);
        }
 
-       ieee80211_tx_skb(sdata, skb, 0);
+       ieee80211_tx_skb(sdata, skb, 1);
        return 0;
 }
 
-void mesh_neighbour_update(u8 *hw_addr, u64 rates, struct ieee80211_sub_if_data *sdata,
+void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data *sdata,
                           bool peer_accepting_plinks)
 {
        struct ieee80211_local *local = sdata->local;
@@ -243,7 +244,7 @@ void mesh_neighbour_update(u8 *hw_addr, u64 rates, struct ieee80211_sub_if_data
        }
 
        sta->last_rx = jiffies;
-       sta->supp_rates[local->hw.conf.channel->band] = rates;
+       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
        if (peer_accepting_plinks && sta->plink_state == PLINK_LISTEN &&
                        sdata->u.mesh.accepting_plinks &&
                        sdata->u.mesh.mshcfg.auto_open_plinks)
@@ -257,9 +258,6 @@ static void mesh_plink_timer(unsigned long data)
        struct sta_info *sta;
        __le16 llid, plid, reason;
        struct ieee80211_sub_if_data *sdata;
-#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
-       DECLARE_MAC_BUF(mac);
-#endif
 
        /*
         * This STA is valid because sta_info_destroy() will
@@ -268,14 +266,19 @@ static void mesh_plink_timer(unsigned long data)
         */
        sta = (struct sta_info *) data;
 
+       if (sta->sdata->local->quiescing) {
+               sta->plink_timer_was_running = true;
+               return;
+       }
+
        spin_lock_bh(&sta->lock);
        if (sta->ignore_plink_timer) {
                sta->ignore_plink_timer = false;
                spin_unlock_bh(&sta->lock);
                return;
        }
-       mpl_dbg("Mesh plink timer for %s fired on state %d\n",
-                       print_mac(mac, sta->addr), sta->plink_state);
+       mpl_dbg("Mesh plink timer for %pM fired on state %d\n",
+               sta->sta.addr, sta->plink_state);
        reason = 0;
        llid = sta->llid;
        plid = sta->plid;
@@ -287,16 +290,16 @@ static void mesh_plink_timer(unsigned long data)
                /* retry timer */
                if (sta->plink_retries < dot11MeshMaxRetries(sdata)) {
                        u32 rand;
-                       mpl_dbg("Mesh plink for %s (retry, timeout): %d %d\n",
-                                       print_mac(mac, sta->addr),
-                                       sta->plink_retries, sta->plink_timeout);
+                       mpl_dbg("Mesh plink for %pM (retry, timeout): %d %d\n",
+                               sta->sta.addr, sta->plink_retries,
+                               sta->plink_timeout);
                        get_random_bytes(&rand, sizeof(u32));
                        sta->plink_timeout = sta->plink_timeout +
                                             rand % sta->plink_timeout;
                        ++sta->plink_retries;
                        mod_plink_timer(sta, sta->plink_timeout);
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_OPEN, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_OPEN, sta->sta.addr, llid,
                                            0, 0);
                        break;
                }
@@ -309,7 +312,7 @@ static void mesh_plink_timer(unsigned long data)
                sta->plink_state = PLINK_HOLDING;
                mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
                spin_unlock_bh(&sta->lock);
-               mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->addr, llid, plid,
+               mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid, plid,
                                    reason);
                break;
        case PLINK_HOLDING:
@@ -324,6 +327,22 @@ static void mesh_plink_timer(unsigned long data)
        }
 }
 
+#ifdef CONFIG_PM
+void mesh_plink_quiesce(struct sta_info *sta)
+{
+       if (del_timer_sync(&sta->plink_timer))
+               sta->plink_timer_was_running = true;
+}
+
+void mesh_plink_restart(struct sta_info *sta)
+{
+       if (sta->plink_timer_was_running) {
+               add_timer(&sta->plink_timer);
+               sta->plink_timer_was_running = false;
+       }
+}
+#endif
+
 static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
 {
        sta->plink_timer.expires = jiffies + (HZ * timeout / 1000);
@@ -337,9 +356,6 @@ int mesh_plink_open(struct sta_info *sta)
 {
        __le16 llid;
        struct ieee80211_sub_if_data *sdata = sta->sdata;
-#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
-       DECLARE_MAC_BUF(mac);
-#endif
 
        spin_lock_bh(&sta->lock);
        get_random_bytes(&llid, 2);
@@ -351,59 +367,21 @@ int mesh_plink_open(struct sta_info *sta)
        sta->plink_state = PLINK_OPN_SNT;
        mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
        spin_unlock_bh(&sta->lock);
-       mpl_dbg("Mesh plink: starting establishment with %s\n",
-               print_mac(mac, sta->addr));
+       mpl_dbg("Mesh plink: starting establishment with %pM\n",
+               sta->sta.addr);
 
        return mesh_plink_frame_tx(sdata, PLINK_OPEN,
-                                  sta->addr, llid, 0, 0);
+                                  sta->sta.addr, llid, 0, 0);
 }
 
 void mesh_plink_block(struct sta_info *sta)
 {
-#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
-       DECLARE_MAC_BUF(mac);
-#endif
-
        spin_lock_bh(&sta->lock);
        __mesh_plink_deactivate(sta);
        sta->plink_state = PLINK_BLOCKED;
        spin_unlock_bh(&sta->lock);
 }
 
-int mesh_plink_close(struct sta_info *sta)
-{
-       struct ieee80211_sub_if_data *sdata = sta->sdata;
-       __le16 llid, plid, reason;
-#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
-       DECLARE_MAC_BUF(mac);
-#endif
-
-       mpl_dbg("Mesh plink: closing link with %s\n",
-                       print_mac(mac, sta->addr));
-       spin_lock_bh(&sta->lock);
-       sta->reason = cpu_to_le16(MESH_LINK_CANCELLED);
-       reason = sta->reason;
-
-       if (sta->plink_state == PLINK_LISTEN ||
-           sta->plink_state == PLINK_BLOCKED) {
-               mesh_plink_fsm_restart(sta);
-               spin_unlock_bh(&sta->lock);
-               return 0;
-       } else if (sta->plink_state == PLINK_ESTAB) {
-               __mesh_plink_deactivate(sta);
-               /* The timer should not be running */
-               mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
-       } else if (!mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata)))
-               sta->ignore_plink_timer = true;
-
-       sta->plink_state = PLINK_HOLDING;
-       llid = sta->llid;
-       plid = sta->plid;
-       spin_unlock_bh(&sta->lock);
-       mesh_plink_frame_tx(sta->sdata, PLINK_CLOSE, sta->addr, llid,
-                           plid, reason);
-       return 0;
-}
 
 void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
                         size_t len, struct ieee80211_rx_status *rx_status)
@@ -417,9 +395,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
        u8 ie_len;
        u8 *baseaddr;
        __le16 plid, llid, reason;
-#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
-       DECLARE_MAC_BUF(mac);
-#endif
 
        /* need action_code, aux */
        if (len < IEEE80211_MIN_ACTION_SIZE + 3)
@@ -434,7 +409,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
        baselen = (u8 *) mgmt->u.action.u.plink_action.variable - (u8 *) mgmt;
        if (mgmt->u.action.u.plink_action.action_code == PLINK_CONFIRM) {
                baseaddr += 4;
-               baselen -= 4;
+               baselen += 4;
        }
        ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
        if (!elems.peer_link) {
@@ -493,7 +468,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                spin_lock_bh(&sta->lock);
        } else if (!sta) {
                /* ftype == PLINK_OPEN */
-               u64 rates;
+               u32 rates;
                if (!mesh_plink_free_count(sdata)) {
                        mpl_dbg("Mesh plink error: no more free plinks\n");
                        rcu_read_unlock();
@@ -557,10 +532,10 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                }
        }
 
-       mpl_dbg("Mesh plink (peer, state, llid, plid, event): %s %d %d %d %d\n",
-                       print_mac(mac, mgmt->sa), sta->plink_state,
-                       le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
-                       event);
+       mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %d %d %d %d\n",
+               mgmt->sa, sta->plink_state,
+               le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
+               event);
        reason = 0;
        switch (sta->plink_state) {
                /* spin_unlock as soon as state is updated at each case */
@@ -577,9 +552,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        sta->llid = llid;
                        mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_OPEN, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_OPEN, sta->sta.addr, llid,
                                            0, 0);
-                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->addr,
+                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr,
                                            llid, plid, 0);
                        break;
                default:
@@ -604,7 +579,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
 
                        llid = sta->llid;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
                                            plid, reason);
                        break;
                case OPN_ACPT:
@@ -613,7 +588,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        sta->plid = plid;
                        llid = sta->llid;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
                                            plid, 0);
                        break;
                case CNF_ACPT:
@@ -646,13 +621,13 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
 
                        llid = sta->llid;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
                                            plid, reason);
                        break;
                case OPN_ACPT:
                        llid = sta->llid;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
                                            plid, 0);
                        break;
                case CNF_ACPT:
@@ -660,8 +635,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        sta->plink_state = PLINK_ESTAB;
                        mesh_plink_inc_estab_count(sdata);
                        spin_unlock_bh(&sta->lock);
-                       mpl_dbg("Mesh plink with %s ESTABLISHED\n",
-                                       print_mac(mac, sta->addr));
+                       mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
+                               sta->sta.addr);
                        break;
                default:
                        spin_unlock_bh(&sta->lock);
@@ -685,7 +660,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
 
                        llid = sta->llid;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
                                            plid, reason);
                        break;
                case OPN_ACPT:
@@ -693,9 +668,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        sta->plink_state = PLINK_ESTAB;
                        mesh_plink_inc_estab_count(sdata);
                        spin_unlock_bh(&sta->lock);
-                       mpl_dbg("Mesh plink with %s ESTABLISHED\n",
-                                       print_mac(mac, sta->addr));
-                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->addr, llid,
+                       mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
+                               sta->sta.addr);
+                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
                                            plid, 0);
                        break;
                default:
@@ -714,13 +689,13 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        llid = sta->llid;
                        mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
                                            plid, reason);
                        break;
                case OPN_ACPT:
                        llid = sta->llid;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->addr, llid,
+                       mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
                                            plid, 0);
                        break;
                default:
@@ -743,8 +718,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        llid = sta->llid;
                        reason = sta->reason;
                        spin_unlock_bh(&sta->lock);
-                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->addr, llid,
-                                           plid, reason);
+                       mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr,
+                                           llid, plid, reason);
                        break;
                default:
                        spin_unlock_bh(&sta->lock);