Merge branch 'for-linus' of git://neil.brown.name/md
[pandora-kernel.git] / net / mac80211 / mesh.c
index da5e981..a7078fd 100644 (file)
 #include "ieee80211_i.h"
 #include "mesh.h"
 
-#define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
-#define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
-#define IEEE80211_MESH_RANN_INTERVAL        (1 * HZ)
-
 #define MESHCONF_CAPAB_ACCEPT_PLINKS 0x01
 #define MESHCONF_CAPAB_FORWARDING    0x08
 
 int mesh_allocated;
 static struct kmem_cache *rm_cache;
 
+#ifdef CONFIG_MAC80211_MESH
+bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
+{
+       return (mgmt->u.action.u.mesh_action.action_code ==
+                       WLAN_MESH_ACTION_HWMP_PATH_SELECTION);
+}
+#else
+bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
+{ return false; }
+#endif
+
 void ieee80211s_init(void)
 {
        mesh_pathtbl_init();
@@ -193,10 +200,9 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
        }
 
        p = kmem_cache_alloc(rm_cache, GFP_ATOMIC);
-       if (!p) {
-               printk(KERN_DEBUG "o11s: could not allocate RMC entry\n");
+       if (!p)
                return 0;
-       }
+
        p->seqnum = seqnum;
        p->exp_time = jiffies + RMC_TIMEOUT;
        memcpy(p->sa, sa, ETH_ALEN);
@@ -314,64 +320,6 @@ mesh_add_rsn_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
        return 0;
 }
 
-int
-mesh_add_srates_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
-{
-       struct ieee80211_local *local = sdata->local;
-       struct ieee80211_supported_band *sband;
-       int rate;
-       u8 i, rates, *pos;
-
-       sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
-       rates = sband->n_bitrates;
-       if (rates > 8)
-               rates = 8;
-
-       if (skb_tailroom(skb) < rates + 2)
-               return -ENOMEM;
-
-       pos = skb_put(skb, rates + 2);
-       *pos++ = WLAN_EID_SUPP_RATES;
-       *pos++ = rates;
-       for (i = 0; i < rates; i++) {
-               rate = sband->bitrates[i].bitrate;
-               *pos++ = (u8) (rate / 5);
-       }
-
-       return 0;
-}
-
-int
-mesh_add_ext_srates_ie(struct sk_buff *skb,
-                      struct ieee80211_sub_if_data *sdata)
-{
-       struct ieee80211_local *local = sdata->local;
-       struct ieee80211_supported_band *sband;
-       int rate;
-       u8 i, exrates, *pos;
-
-       sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
-       exrates = sband->n_bitrates;
-       if (exrates > 8)
-               exrates -= 8;
-       else
-               exrates = 0;
-
-       if (skb_tailroom(skb) < exrates + 2)
-               return -ENOMEM;
-
-       if (exrates) {
-               pos = skb_put(skb, exrates + 2);
-               *pos++ = WLAN_EID_EXT_SUPP_RATES;
-               *pos++ = exrates;
-               for (i = 8; i < sband->n_bitrates; i++) {
-                       rate = sband->bitrates[i].bitrate;
-                       *pos++ = (u8) (rate / 5);
-               }
-       }
-       return 0;
-}
-
 int mesh_add_ds_params_ie(struct sk_buff *skb,
                          struct ieee80211_sub_if_data *sdata)
 {
@@ -457,8 +405,7 @@ int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
                memcpy(hdr->addr3, meshsa, ETH_ALEN);
                return 24;
        } else {
-               *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS |
-                               IEEE80211_FCTL_TODS);
+               *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
                /* RA TA DA SA */
                memset(hdr->addr1, 0, ETH_ALEN);   /* RA is resolved later */
                memcpy(hdr->addr2, meshsa, ETH_ALEN);
@@ -530,7 +477,8 @@ static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata)
 
        mesh_path_tx_root_frame(sdata);
        mod_timer(&ifmsh->mesh_path_root_timer,
-                 round_jiffies(jiffies + IEEE80211_MESH_RANN_INTERVAL));
+                 round_jiffies(TU_TO_EXP_TIME(
+                                 ifmsh->mshcfg.dot11MeshHWMPRannInterval)));
 }
 
 #ifdef CONFIG_PM
@@ -538,7 +486,7 @@ void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 
-       /* use atomic bitops in case both timers fire at the same time */
+       /* use atomic bitops in case all timers fire at the same time */
 
        if (del_timer_sync(&ifmsh->housekeeping_timer))
                set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
@@ -671,8 +619,9 @@ static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
                        break;
                }
                break;
-       case WLAN_CATEGORY_MESH_PATH_SEL:
-               mesh_rx_path_sel_frame(sdata, mgmt, len);
+       case WLAN_CATEGORY_MESH_ACTION:
+               if (mesh_action_is_path_sel(mgmt))
+                       mesh_rx_path_sel_frame(sdata, mgmt, len);
                break;
        }
 }
@@ -744,6 +693,7 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
        ifmsh->accepting_plinks = true;
        ifmsh->preq_id = 0;
        ifmsh->sn = 0;
+       ifmsh->num_gates = 0;
        atomic_set(&ifmsh->mpaths, 0);
        mesh_rmc_init(sdata);
        ifmsh->last_preq = jiffies;