]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/mac80211/mesh.c
memcg: remove redundant initialization in mem_cgroup_create()
[linux-2.6-omap-h63xx.git] / net / mac80211 / mesh.c
index 8ff533005d929288a4b38d969756d9e9b599c8d3..594a3356a5082c3c33760c67254cac02133f42fb 100644 (file)
@@ -48,11 +48,6 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct net_device *dev)
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        struct ieee80211_if_sta *sta = &sdata->u.sta;
 
-       if (sta->mesh_id_len == ie->mesh_id_len &&
-               memcmp(sta->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
-               memcmp(sta->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 &&
-               memcmp(sta->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 &&
-               memcmp(sta->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0)
        /*
         * As support for each feature is added, check for matching
         * - On mesh config capabilities
@@ -63,6 +58,11 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct net_device *dev)
         *   - MDA enabled
         * - Power management control on fc
         */
+       if (sta->mesh_id_len == ie->mesh_id_len &&
+               memcmp(sta->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
+               memcmp(sta->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 &&
+               memcmp(sta->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 &&
+               memcmp(sta->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0)
                return true;
 
        return false;
@@ -83,18 +83,17 @@ bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie,
 /**
  * mesh_accept_plinks_update: update accepting_plink in local mesh beacons
  *
- * @dev: mesh interface in which mesh beacons are going to be updated
+ * @sdata: mesh interface in which mesh beacons are going to be updated
  */
-void mesh_accept_plinks_update(struct net_device *dev)
+void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
 {
-       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        bool free_plinks;
 
        /* In case mesh_plink_free_count > 0 and mesh_plinktbl_capacity == 0,
         * the mesh interface might be able to establish plinks with peers that
-        * are already on the table but are not on ESTAB state. However, in
-        * general the mesh interface is not accepting peer link requests from
-        * new peers, and that must be reflected in the beacon
+        * are already on the table but are not on PLINK_ESTAB state. However,
+        * in general the mesh interface is not accepting peer link requests
+        * from new peers, and that must be reflected in the beacon
         */
        free_plinks = mesh_plink_availables(sdata);
 
@@ -381,3 +380,70 @@ endgrow:
        else
                return newtbl;
 }
+
+/**
+ * ieee80211_new_mesh_header - create a new mesh header
+ * @meshhdr:    uninitialized mesh header
+ * @sdata:     mesh interface to be used
+ *
+ * Return the header length.
+ */
+int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
+               struct ieee80211_sub_if_data *sdata)
+{
+       meshhdr->flags = 0;
+       meshhdr->ttl = sdata->u.sta.mshcfg.dot11MeshTTL;
+
+       meshhdr->seqnum[0] = sdata->u.sta.mesh_seqnum[0]++;
+       meshhdr->seqnum[1] = sdata->u.sta.mesh_seqnum[1];
+       meshhdr->seqnum[2] = sdata->u.sta.mesh_seqnum[2];
+
+       if (sdata->u.sta.mesh_seqnum[0] == 0) {
+               sdata->u.sta.mesh_seqnum[1]++;
+               if (sdata->u.sta.mesh_seqnum[1] == 0)
+                       sdata->u.sta.mesh_seqnum[2]++;
+       }
+
+       return 5;
+}
+
+void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
+{
+       struct ieee80211_if_sta *ifsta = &sdata->u.sta;
+
+       ifsta->mshcfg.dot11MeshRetryTimeout = MESH_RET_T;
+       ifsta->mshcfg.dot11MeshConfirmTimeout = MESH_CONF_T;
+       ifsta->mshcfg.dot11MeshHoldingTimeout = MESH_HOLD_T;
+       ifsta->mshcfg.dot11MeshMaxRetries = MESH_MAX_RETR;
+       ifsta->mshcfg.dot11MeshTTL = MESH_TTL;
+       ifsta->mshcfg.auto_open_plinks = true;
+       ifsta->mshcfg.dot11MeshMaxPeerLinks =
+               MESH_MAX_ESTAB_PLINKS;
+       ifsta->mshcfg.dot11MeshHWMPactivePathTimeout =
+               MESH_PATH_TIMEOUT;
+       ifsta->mshcfg.dot11MeshHWMPpreqMinInterval =
+               MESH_PREQ_MIN_INT;
+       ifsta->mshcfg.dot11MeshHWMPnetDiameterTraversalTime =
+               MESH_DIAM_TRAVERSAL_TIME;
+       ifsta->mshcfg.dot11MeshHWMPmaxPREQretries =
+               MESH_MAX_PREQ_RETRIES;
+       ifsta->mshcfg.path_refresh_time =
+               MESH_PATH_REFRESH_TIME;
+       ifsta->mshcfg.min_discovery_timeout =
+               MESH_MIN_DISCOVERY_TIMEOUT;
+       ifsta->accepting_plinks = true;
+       ifsta->preq_id = 0;
+       ifsta->dsn = 0;
+       atomic_set(&ifsta->mpaths, 0);
+       mesh_rmc_init(sdata->dev);
+       ifsta->last_preq = jiffies;
+       /* Allocate all mesh structures when creating the first mesh interface. */
+       if (!mesh_allocated)
+               ieee80211s_init();
+       mesh_ids_set_default(ifsta);
+       setup_timer(&ifsta->mesh_path_timer,
+                   ieee80211_mesh_path_timer,
+                   (unsigned long) sdata);
+       INIT_LIST_HEAD(&ifsta->preq_queue.list);
+       spin_lock_init(&ifsta->mesh_preq_queue_lock);
+}