Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 1 | /* |
Rui Paulo | 264d9b7 | 2009-11-09 23:46:58 +0000 | [diff] [blame] | 2 | * Copyright (c) 2008, 2009 open80211s Ltd. |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 3 | * Authors: Luis Carlos Cobo <luisca@cozybit.com> |
| 4 | * Javier Cardona <javier@cozybit.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/slab.h> |
Luis Carlos Cobo | 51cedda | 2008-04-23 12:15:29 -0700 | [diff] [blame] | 12 | #include <asm/unaligned.h> |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 13 | #include "ieee80211_i.h" |
| 14 | #include "mesh.h" |
| 15 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 16 | #define TMR_RUNNING_HK 0 |
| 17 | #define TMR_RUNNING_MP 1 |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 18 | #define TMR_RUNNING_MPR 2 |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 19 | |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 20 | int mesh_allocated; |
| 21 | static struct kmem_cache *rm_cache; |
| 22 | |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 23 | bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt) |
| 24 | { |
| 25 | return (mgmt->u.action.u.mesh_action.action_code == |
| 26 | WLAN_MESH_ACTION_HWMP_PATH_SELECTION); |
| 27 | } |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 28 | |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 29 | void ieee80211s_init(void) |
| 30 | { |
| 31 | mesh_pathtbl_init(); |
| 32 | mesh_allocated = 1; |
| 33 | rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry), |
| 34 | 0, 0, NULL); |
| 35 | } |
| 36 | |
| 37 | void ieee80211s_stop(void) |
| 38 | { |
| 39 | mesh_pathtbl_unregister(); |
| 40 | kmem_cache_destroy(rm_cache); |
| 41 | } |
| 42 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 43 | static void ieee80211_mesh_housekeeping_timer(unsigned long data) |
| 44 | { |
| 45 | struct ieee80211_sub_if_data *sdata = (void *) data; |
| 46 | struct ieee80211_local *local = sdata->local; |
| 47 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 48 | |
Rui Paulo | 6b9ac44 | 2009-10-20 21:21:48 +0100 | [diff] [blame] | 49 | set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags); |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 50 | |
| 51 | if (local->quiescing) { |
| 52 | set_bit(TMR_RUNNING_HK, &ifmsh->timers_running); |
| 53 | return; |
| 54 | } |
| 55 | |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 56 | ieee80211_queue_work(&local->hw, &sdata->work); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 57 | } |
| 58 | |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 59 | /** |
| 60 | * mesh_matches_local - check if the config of a mesh point matches ours |
| 61 | * |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 62 | * @sdata: local mesh subif |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 63 | * @ie: information elements of a management frame from the mesh peer |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 64 | * |
| 65 | * This function checks if the mesh configuration of a mesh point matches the |
| 66 | * local mesh configuration, i.e. if both nodes belong to the same mesh network. |
| 67 | */ |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 68 | bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, |
| 69 | struct ieee802_11_elems *ie) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 70 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 71 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Thomas Pedersen | 739522b | 2011-10-26 14:47:28 -0700 | [diff] [blame] | 72 | struct ieee80211_local *local = sdata->local; |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 73 | u32 basic_rates = 0; |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 74 | struct cfg80211_chan_def sta_chan_def; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 75 | |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 76 | /* |
| 77 | * As support for each feature is added, check for matching |
| 78 | * - On mesh config capabilities |
| 79 | * - Power Save Support En |
| 80 | * - Sync support enabled |
| 81 | * - Sync support active |
| 82 | * - Sync support required from peer |
| 83 | * - MDA enabled |
| 84 | * - Power management control on fc |
| 85 | */ |
Thomas Pedersen | 739522b | 2011-10-26 14:47:28 -0700 | [diff] [blame] | 86 | if (!(ifmsh->mesh_id_len == ie->mesh_id_len && |
| 87 | memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && |
| 88 | (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) && |
| 89 | (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) && |
| 90 | (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && |
| 91 | (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && |
| 92 | (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) |
| 93 | goto mismatch; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 94 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 95 | ieee80211_sta_get_rates(local, ie, ieee80211_get_sdata_band(sdata), |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 96 | &basic_rates); |
| 97 | |
Ashok Nagarajan | fe40cb6 | 2012-04-02 21:21:22 -0700 | [diff] [blame] | 98 | if (sdata->vif.bss_conf.basic_rates != basic_rates) |
| 99 | goto mismatch; |
| 100 | |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 101 | ieee80211_ht_oper_to_chandef(sdata->vif.bss_conf.chandef.chan, |
| 102 | ie->ht_operation, &sta_chan_def); |
Ashok Nagarajan | b91e64a | 2012-04-30 14:20:31 -0700 | [diff] [blame] | 103 | |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 104 | if (!cfg80211_chandef_compatible(&sdata->vif.bss_conf.chandef, |
| 105 | &sta_chan_def)) |
Thomas Pedersen | 739522b | 2011-10-26 14:47:28 -0700 | [diff] [blame] | 106 | goto mismatch; |
| 107 | |
| 108 | return true; |
| 109 | mismatch: |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 110 | return false; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * mesh_peer_accepts_plinks - check if an mp is willing to establish peer links |
| 115 | * |
| 116 | * @ie: information elements of a management frame from the mesh peer |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 117 | */ |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 118 | bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 119 | { |
Rui Paulo | 136cfa2 | 2009-11-18 18:40:00 +0000 | [diff] [blame] | 120 | return (ie->mesh_config->meshconf_cap & |
Marco Porsch | 6582163 | 2012-11-21 18:40:30 -0800 | [diff] [blame] | 121 | IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /** |
Ben Hutchings | 2c53040 | 2012-07-10 10:55:09 +0000 | [diff] [blame] | 125 | * mesh_accept_plinks_update - update accepting_plink in local mesh beacons |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 126 | * |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 127 | * @sdata: mesh interface in which mesh beacons are going to be updated |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 128 | * |
| 129 | * Returns: beacon changed flag if the beacon content changed. |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 130 | */ |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 131 | u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 132 | { |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 133 | bool free_plinks; |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 134 | u32 changed = 0; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 135 | |
| 136 | /* In case mesh_plink_free_count > 0 and mesh_plinktbl_capacity == 0, |
| 137 | * the mesh interface might be able to establish plinks with peers that |
Luis Carlos Cobo | b4e08ea | 2008-02-29 15:46:08 -0800 | [diff] [blame] | 138 | * are already on the table but are not on PLINK_ESTAB state. However, |
| 139 | * in general the mesh interface is not accepting peer link requests |
| 140 | * from new peers, and that must be reflected in the beacon |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 141 | */ |
| 142 | free_plinks = mesh_plink_availables(sdata); |
| 143 | |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 144 | if (free_plinks != sdata->u.mesh.accepting_plinks) { |
| 145 | sdata->u.mesh.accepting_plinks = free_plinks; |
| 146 | changed = BSS_CHANGED_BEACON; |
| 147 | } |
| 148 | |
| 149 | return changed; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 150 | } |
| 151 | |
Thomas Pedersen | 45b5028 | 2013-02-06 10:17:21 -0800 | [diff] [blame] | 152 | /* |
| 153 | * mesh_sta_cleanup - clean up any mesh sta state |
| 154 | * |
| 155 | * @sta: mesh sta to clean up. |
| 156 | */ |
| 157 | void mesh_sta_cleanup(struct sta_info *sta) |
| 158 | { |
| 159 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
| 160 | u32 changed; |
| 161 | |
| 162 | /* |
| 163 | * maybe userspace handles peer allocation and peering, but in either |
| 164 | * case the beacon is still generated by the kernel and we might need |
| 165 | * an update. |
| 166 | */ |
| 167 | changed = mesh_accept_plinks_update(sdata); |
| 168 | if (sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) { |
| 169 | changed |= mesh_plink_deactivate(sta); |
| 170 | del_timer_sync(&sta->plink_timer); |
| 171 | } |
| 172 | |
| 173 | if (changed) |
| 174 | ieee80211_bss_info_change_notify(sdata, changed); |
| 175 | } |
| 176 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 177 | int mesh_rmc_init(struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 178 | { |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 179 | int i; |
| 180 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 181 | sdata->u.mesh.rmc = kmalloc(sizeof(struct mesh_rmc), GFP_KERNEL); |
| 182 | if (!sdata->u.mesh.rmc) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 183 | return -ENOMEM; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 184 | sdata->u.mesh.rmc->idx_mask = RMC_BUCKETS - 1; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 185 | for (i = 0; i < RMC_BUCKETS; i++) |
Thomas Pedersen | b7cfcd1 | 2012-12-17 18:41:57 -0800 | [diff] [blame] | 186 | INIT_LIST_HEAD(&sdata->u.mesh.rmc->bucket[i]); |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 190 | void mesh_rmc_free(struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 191 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 192 | struct mesh_rmc *rmc = sdata->u.mesh.rmc; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 193 | struct rmc_entry *p, *n; |
| 194 | int i; |
| 195 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 196 | if (!sdata->u.mesh.rmc) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 197 | return; |
| 198 | |
| 199 | for (i = 0; i < RMC_BUCKETS; i++) |
Thomas Pedersen | b7cfcd1 | 2012-12-17 18:41:57 -0800 | [diff] [blame] | 200 | list_for_each_entry_safe(p, n, &rmc->bucket[i], list) { |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 201 | list_del(&p->list); |
| 202 | kmem_cache_free(rm_cache, p); |
| 203 | } |
| 204 | |
| 205 | kfree(rmc); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 206 | sdata->u.mesh.rmc = NULL; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
| 210 | * mesh_rmc_check - Check frame in recent multicast cache and add if absent. |
| 211 | * |
| 212 | * @sa: source address |
| 213 | * @mesh_hdr: mesh_header |
| 214 | * |
| 215 | * Returns: 0 if the frame is not in the cache, nonzero otherwise. |
| 216 | * |
| 217 | * Checks using the source address and the mesh sequence number if we have |
| 218 | * received this frame lately. If the frame is not in the cache, it is added to |
| 219 | * it. |
| 220 | */ |
| 221 | int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr, |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 222 | struct ieee80211_sub_if_data *sdata) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 223 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 224 | struct mesh_rmc *rmc = sdata->u.mesh.rmc; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 225 | u32 seqnum = 0; |
| 226 | int entries = 0; |
| 227 | u8 idx; |
| 228 | struct rmc_entry *p, *n; |
| 229 | |
| 230 | /* Don't care about endianness since only match matters */ |
Luis Carlos Cobo | 51cedda | 2008-04-23 12:15:29 -0700 | [diff] [blame] | 231 | memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum)); |
| 232 | idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask; |
Thomas Pedersen | b7cfcd1 | 2012-12-17 18:41:57 -0800 | [diff] [blame] | 233 | list_for_each_entry_safe(p, n, &rmc->bucket[idx], list) { |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 234 | ++entries; |
| 235 | if (time_after(jiffies, p->exp_time) || |
| 236 | (entries == RMC_QUEUE_MAX_LEN)) { |
| 237 | list_del(&p->list); |
| 238 | kmem_cache_free(rm_cache, p); |
| 239 | --entries; |
Joe Perches | f64f9e7 | 2009-11-29 16:55:45 -0800 | [diff] [blame] | 240 | } else if ((seqnum == p->seqnum) && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 241 | (ether_addr_equal(sa, p->sa))) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 242 | return -1; |
| 243 | } |
| 244 | |
| 245 | p = kmem_cache_alloc(rm_cache, GFP_ATOMIC); |
Joe Perches | d15b845 | 2011-08-29 14:17:31 -0700 | [diff] [blame] | 246 | if (!p) |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 247 | return 0; |
Joe Perches | d15b845 | 2011-08-29 14:17:31 -0700 | [diff] [blame] | 248 | |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 249 | p->seqnum = seqnum; |
| 250 | p->exp_time = jiffies + RMC_TIMEOUT; |
| 251 | memcpy(p->sa, sa, ETH_ALEN); |
Thomas Pedersen | b7cfcd1 | 2012-12-17 18:41:57 -0800 | [diff] [blame] | 252 | list_add(&p->list, &rmc->bucket[idx]); |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 253 | return 0; |
| 254 | } |
| 255 | |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 256 | int |
| 257 | mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) |
| 258 | { |
| 259 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 260 | u8 *pos, neighbors; |
| 261 | u8 meshconf_len = sizeof(struct ieee80211_meshconf_ie); |
| 262 | |
| 263 | if (skb_tailroom(skb) < 2 + meshconf_len) |
| 264 | return -ENOMEM; |
| 265 | |
| 266 | pos = skb_put(skb, 2 + meshconf_len); |
| 267 | *pos++ = WLAN_EID_MESH_CONFIG; |
| 268 | *pos++ = meshconf_len; |
| 269 | |
| 270 | /* Active path selection protocol ID */ |
| 271 | *pos++ = ifmsh->mesh_pp_id; |
| 272 | /* Active path selection metric ID */ |
| 273 | *pos++ = ifmsh->mesh_pm_id; |
| 274 | /* Congestion control mode identifier */ |
| 275 | *pos++ = ifmsh->mesh_cc_id; |
| 276 | /* Synchronization protocol identifier */ |
| 277 | *pos++ = ifmsh->mesh_sp_id; |
| 278 | /* Authentication Protocol identifier */ |
| 279 | *pos++ = ifmsh->mesh_auth_id; |
| 280 | /* Mesh Formation Info - number of neighbors */ |
Ashok Nagarajan | 1258d97 | 2012-10-09 13:27:47 -0700 | [diff] [blame] | 281 | neighbors = atomic_read(&ifmsh->estab_plinks); |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 282 | /* Number of neighbor mesh STAs or 15 whichever is smaller */ |
| 283 | neighbors = (neighbors > 15) ? 15 : neighbors; |
| 284 | *pos++ = neighbors << 1; |
| 285 | /* Mesh capability */ |
Marco Porsch | 6582163 | 2012-11-21 18:40:30 -0800 | [diff] [blame] | 286 | *pos = IEEE80211_MESHCONF_CAPAB_FORWARDING; |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 287 | *pos |= ifmsh->accepting_plinks ? |
Marco Porsch | 6582163 | 2012-11-21 18:40:30 -0800 | [diff] [blame] | 288 | IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 289 | /* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */ |
| 290 | *pos |= ifmsh->ps_peers_deep_sleep ? |
| 291 | IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00; |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 292 | *pos++ |= ifmsh->adjusting_tbtt ? |
Marco Porsch | 6582163 | 2012-11-21 18:40:30 -0800 | [diff] [blame] | 293 | IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00; |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 294 | *pos++ = 0x00; |
| 295 | |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | int |
| 300 | mesh_add_meshid_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) |
| 301 | { |
| 302 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 303 | u8 *pos; |
| 304 | |
| 305 | if (skb_tailroom(skb) < 2 + ifmsh->mesh_id_len) |
| 306 | return -ENOMEM; |
| 307 | |
| 308 | pos = skb_put(skb, 2 + ifmsh->mesh_id_len); |
| 309 | *pos++ = WLAN_EID_MESH_ID; |
| 310 | *pos++ = ifmsh->mesh_id_len; |
| 311 | if (ifmsh->mesh_id_len) |
| 312 | memcpy(pos, ifmsh->mesh_id, ifmsh->mesh_id_len); |
| 313 | |
| 314 | return 0; |
| 315 | } |
| 316 | |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 317 | int mesh_add_awake_window_ie(struct sk_buff *skb, |
| 318 | struct ieee80211_sub_if_data *sdata) |
| 319 | { |
| 320 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 321 | u8 *pos; |
| 322 | |
| 323 | /* see IEEE802.11-2012 13.14.6 */ |
| 324 | if (ifmsh->ps_peers_light_sleep == 0 && |
| 325 | ifmsh->ps_peers_deep_sleep == 0 && |
| 326 | ifmsh->nonpeer_pm == NL80211_MESH_POWER_ACTIVE) |
| 327 | return 0; |
| 328 | |
| 329 | if (skb_tailroom(skb) < 4) |
| 330 | return -ENOMEM; |
| 331 | |
| 332 | pos = skb_put(skb, 2 + 2); |
| 333 | *pos++ = WLAN_EID_MESH_AWAKE_WINDOW; |
| 334 | *pos++ = 2; |
| 335 | put_unaligned_le16(ifmsh->mshcfg.dot11MeshAwakeWindowDuration, pos); |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 340 | int |
| 341 | mesh_add_vendor_ies(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) |
| 342 | { |
| 343 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 344 | u8 offset, len; |
| 345 | const u8 *data; |
| 346 | |
| 347 | if (!ifmsh->ie || !ifmsh->ie_len) |
| 348 | return 0; |
| 349 | |
| 350 | /* fast-forward to vendor IEs */ |
| 351 | offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0); |
| 352 | |
| 353 | if (offset) { |
| 354 | len = ifmsh->ie_len - offset; |
| 355 | data = ifmsh->ie + offset; |
| 356 | if (skb_tailroom(skb) < len) |
| 357 | return -ENOMEM; |
| 358 | memcpy(skb_put(skb, len), data, len); |
| 359 | } |
| 360 | |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | int |
| 365 | mesh_add_rsn_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) |
| 366 | { |
| 367 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 368 | u8 len = 0; |
| 369 | const u8 *data; |
| 370 | |
| 371 | if (!ifmsh->ie || !ifmsh->ie_len) |
| 372 | return 0; |
| 373 | |
| 374 | /* find RSN IE */ |
| 375 | data = ifmsh->ie; |
| 376 | while (data < ifmsh->ie + ifmsh->ie_len) { |
| 377 | if (*data == WLAN_EID_RSN) { |
| 378 | len = data[1] + 2; |
| 379 | break; |
| 380 | } |
| 381 | data++; |
| 382 | } |
| 383 | |
| 384 | if (len) { |
| 385 | if (skb_tailroom(skb) < len) |
| 386 | return -ENOMEM; |
| 387 | memcpy(skb_put(skb, len), data, len); |
| 388 | } |
| 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 393 | int mesh_add_ds_params_ie(struct sk_buff *skb, |
| 394 | struct ieee80211_sub_if_data *sdata) |
| 395 | { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 396 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 397 | struct ieee80211_channel *chan; |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 398 | u8 *pos; |
| 399 | |
| 400 | if (skb_tailroom(skb) < 3) |
| 401 | return -ENOMEM; |
| 402 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 403 | rcu_read_lock(); |
| 404 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 405 | if (WARN_ON(!chanctx_conf)) { |
| 406 | rcu_read_unlock(); |
| 407 | return -EINVAL; |
| 408 | } |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 409 | chan = chanctx_conf->def.chan; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 410 | rcu_read_unlock(); |
| 411 | |
Emanuel Taube | 601513a | 2013-02-06 14:17:17 +0100 | [diff] [blame] | 412 | pos = skb_put(skb, 2 + 1); |
| 413 | *pos++ = WLAN_EID_DS_PARAMS; |
| 414 | *pos++ = 1; |
| 415 | *pos++ = ieee80211_frequency_to_channel(chan->center_freq); |
Rui Paulo | be125c6 | 2009-11-09 23:46:54 +0000 | [diff] [blame] | 416 | |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 417 | return 0; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 418 | } |
| 419 | |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 420 | int mesh_add_ht_cap_ie(struct sk_buff *skb, |
| 421 | struct ieee80211_sub_if_data *sdata) |
| 422 | { |
| 423 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 424 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 425 | struct ieee80211_supported_band *sband; |
| 426 | u8 *pos; |
| 427 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 428 | sband = local->hw.wiphy->bands[band]; |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 429 | if (!sband->ht_cap.ht_supported || |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 430 | sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 431 | return 0; |
| 432 | |
| 433 | if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap)) |
| 434 | return -ENOMEM; |
| 435 | |
| 436 | pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_cap)); |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 437 | ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, sband->ht_cap.cap); |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 438 | |
| 439 | return 0; |
| 440 | } |
| 441 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 442 | int mesh_add_ht_oper_ie(struct sk_buff *skb, |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 443 | struct ieee80211_sub_if_data *sdata) |
| 444 | { |
| 445 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 446 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 447 | struct ieee80211_channel *channel; |
Johannes Berg | 466f310 | 2012-07-25 13:51:49 +0200 | [diff] [blame] | 448 | enum nl80211_channel_type channel_type = |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 449 | cfg80211_get_chandef_type(&sdata->vif.bss_conf.chandef); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 450 | struct ieee80211_supported_band *sband; |
| 451 | struct ieee80211_sta_ht_cap *ht_cap; |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 452 | u8 *pos; |
| 453 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 454 | rcu_read_lock(); |
| 455 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 456 | if (WARN_ON(!chanctx_conf)) { |
| 457 | rcu_read_unlock(); |
| 458 | return -EINVAL; |
| 459 | } |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 460 | channel = chanctx_conf->def.chan; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 461 | rcu_read_unlock(); |
| 462 | |
| 463 | sband = local->hw.wiphy->bands[channel->band]; |
| 464 | ht_cap = &sband->ht_cap; |
| 465 | |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 466 | if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT) |
| 467 | return 0; |
| 468 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 469 | if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_operation)) |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 470 | return -ENOMEM; |
| 471 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 472 | pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_operation)); |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 473 | ieee80211_ie_build_ht_oper(pos, ht_cap, &sdata->vif.bss_conf.chandef, |
Ashok Nagarajan | 431e315 | 2012-04-30 14:20:29 -0700 | [diff] [blame] | 474 | sdata->vif.bss_conf.ht_operation_mode); |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 475 | |
| 476 | return 0; |
| 477 | } |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 478 | static void ieee80211_mesh_path_timer(unsigned long data) |
| 479 | { |
| 480 | struct ieee80211_sub_if_data *sdata = |
| 481 | (struct ieee80211_sub_if_data *) data; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 482 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Johannes Berg | 133b822 | 2008-09-16 14:18:59 +0200 | [diff] [blame] | 483 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 484 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 485 | if (local->quiescing) { |
| 486 | set_bit(TMR_RUNNING_MP, &ifmsh->timers_running); |
| 487 | return; |
| 488 | } |
| 489 | |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 490 | ieee80211_queue_work(&local->hw, &sdata->work); |
Luis Carlos Cobo | 2e3c873 | 2008-02-23 15:17:09 +0100 | [diff] [blame] | 491 | } |
| 492 | |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 493 | static void ieee80211_mesh_path_root_timer(unsigned long data) |
| 494 | { |
| 495 | struct ieee80211_sub_if_data *sdata = |
| 496 | (struct ieee80211_sub_if_data *) data; |
| 497 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 498 | struct ieee80211_local *local = sdata->local; |
| 499 | |
| 500 | set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags); |
| 501 | |
| 502 | if (local->quiescing) { |
| 503 | set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running); |
| 504 | return; |
| 505 | } |
| 506 | |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 507 | ieee80211_queue_work(&local->hw, &sdata->work); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 510 | void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh) |
| 511 | { |
Chun-Yeow Yeoh | dbb912c | 2012-06-14 02:06:09 +0800 | [diff] [blame] | 512 | if (ifmsh->mshcfg.dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT) |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 513 | set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags); |
| 514 | else { |
| 515 | clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags); |
| 516 | /* stop running timer */ |
| 517 | del_timer_sync(&ifmsh->mesh_path_root_timer); |
| 518 | } |
| 519 | } |
| 520 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 521 | /** |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 522 | * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame |
| 523 | * @hdr: 802.11 frame header |
| 524 | * @fc: frame control field |
| 525 | * @meshda: destination address in the mesh |
| 526 | * @meshsa: source address address in the mesh. Same as TA, as frame is |
| 527 | * locally originated. |
| 528 | * |
| 529 | * Return the length of the 802.11 (does not include a mesh control header) |
| 530 | */ |
Johannes Berg | 15ff636 | 2009-11-17 13:34:04 +0100 | [diff] [blame] | 531 | int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, |
| 532 | const u8 *meshda, const u8 *meshsa) |
| 533 | { |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 534 | if (is_multicast_ether_addr(meshda)) { |
| 535 | *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); |
| 536 | /* DA TA SA */ |
| 537 | memcpy(hdr->addr1, meshda, ETH_ALEN); |
| 538 | memcpy(hdr->addr2, meshsa, ETH_ALEN); |
| 539 | memcpy(hdr->addr3, meshsa, ETH_ALEN); |
| 540 | return 24; |
| 541 | } else { |
Javier Cardona | 2154c81 | 2011-09-07 17:49:53 -0700 | [diff] [blame] | 542 | *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 543 | /* RA TA DA SA */ |
| 544 | memset(hdr->addr1, 0, ETH_ALEN); /* RA is resolved later */ |
| 545 | memcpy(hdr->addr2, meshsa, ETH_ALEN); |
| 546 | memcpy(hdr->addr3, meshda, ETH_ALEN); |
| 547 | memcpy(hdr->addr4, meshsa, ETH_ALEN); |
| 548 | return 30; |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | /** |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 553 | * ieee80211_new_mesh_header - create a new mesh header |
| 554 | * @meshhdr: uninitialized mesh header |
| 555 | * @sdata: mesh interface to be used |
Javier Cardona | 61ad539 | 2010-12-16 17:23:34 -0800 | [diff] [blame] | 556 | * @addr4or5: 1st address in the ae header, which may correspond to address 4 |
| 557 | * (if addr6 is NULL) or address 5 (if addr6 is present). It may |
| 558 | * be NULL. |
| 559 | * @addr6: 2nd address in the ae header, which corresponds to addr6 of the |
| 560 | * mesh frame |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 561 | * |
| 562 | * Return the header length. |
| 563 | */ |
| 564 | int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, |
Javier Cardona | 61ad539 | 2010-12-16 17:23:34 -0800 | [diff] [blame] | 565 | struct ieee80211_sub_if_data *sdata, char *addr4or5, |
| 566 | char *addr6) |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 567 | { |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 568 | int aelen = 0; |
Javier Cardona | 61ad539 | 2010-12-16 17:23:34 -0800 | [diff] [blame] | 569 | BUG_ON(!addr4or5 && addr6); |
Julia Lawall | 0c3cee7 | 2009-12-09 20:25:59 +0100 | [diff] [blame] | 570 | memset(meshhdr, 0, sizeof(*meshhdr)); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 571 | meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; |
| 572 | put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); |
| 573 | sdata->u.mesh.mesh_seqnum++; |
Javier Cardona | 61ad539 | 2010-12-16 17:23:34 -0800 | [diff] [blame] | 574 | if (addr4or5 && !addr6) { |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 575 | meshhdr->flags |= MESH_FLAGS_AE_A4; |
| 576 | aelen += ETH_ALEN; |
Javier Cardona | 61ad539 | 2010-12-16 17:23:34 -0800 | [diff] [blame] | 577 | memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN); |
| 578 | } else if (addr4or5 && addr6) { |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 579 | meshhdr->flags |= MESH_FLAGS_AE_A5_A6; |
| 580 | aelen += 2 * ETH_ALEN; |
Javier Cardona | 61ad539 | 2010-12-16 17:23:34 -0800 | [diff] [blame] | 581 | memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN); |
| 582 | memcpy(meshhdr->eaddr2, addr6, ETH_ALEN); |
Javier Cardona | 3c5772a | 2009-08-10 12:15:48 -0700 | [diff] [blame] | 583 | } |
| 584 | return 6 + aelen; |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 585 | } |
| 586 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 587 | static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata, |
| 588 | struct ieee80211_if_mesh *ifmsh) |
| 589 | { |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 590 | u32 changed; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 591 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 592 | ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT); |
| 593 | mesh_path_expire(sdata); |
| 594 | |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 595 | changed = mesh_accept_plinks_update(sdata); |
| 596 | ieee80211_bss_info_change_notify(sdata, changed); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 597 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 598 | mod_timer(&ifmsh->housekeeping_timer, |
| 599 | round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL)); |
| 600 | } |
| 601 | |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 602 | static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata) |
| 603 | { |
| 604 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Chun-Yeow Yeoh | a69cc44 | 2012-06-14 02:06:07 +0800 | [diff] [blame] | 605 | u32 interval; |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 606 | |
| 607 | mesh_path_tx_root_frame(sdata); |
Chun-Yeow Yeoh | a69cc44 | 2012-06-14 02:06:07 +0800 | [diff] [blame] | 608 | |
| 609 | if (ifmsh->mshcfg.dot11MeshHWMPRootMode == IEEE80211_PROACTIVE_RANN) |
| 610 | interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval; |
| 611 | else |
| 612 | interval = ifmsh->mshcfg.dot11MeshHWMProotInterval; |
| 613 | |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 614 | mod_timer(&ifmsh->mesh_path_root_timer, |
Chun-Yeow Yeoh | a69cc44 | 2012-06-14 02:06:07 +0800 | [diff] [blame] | 615 | round_jiffies(TU_TO_EXP_TIME(interval))); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 616 | } |
| 617 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 618 | #ifdef CONFIG_PM |
| 619 | void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata) |
| 620 | { |
| 621 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 622 | |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 623 | /* use atomic bitops in case all timers fire at the same time */ |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 624 | |
| 625 | if (del_timer_sync(&ifmsh->housekeeping_timer)) |
| 626 | set_bit(TMR_RUNNING_HK, &ifmsh->timers_running); |
| 627 | if (del_timer_sync(&ifmsh->mesh_path_timer)) |
| 628 | set_bit(TMR_RUNNING_MP, &ifmsh->timers_running); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 629 | if (del_timer_sync(&ifmsh->mesh_path_root_timer)) |
| 630 | set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running); |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) |
| 634 | { |
| 635 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 636 | |
| 637 | if (test_and_clear_bit(TMR_RUNNING_HK, &ifmsh->timers_running)) |
| 638 | add_timer(&ifmsh->housekeeping_timer); |
| 639 | if (test_and_clear_bit(TMR_RUNNING_MP, &ifmsh->timers_running)) |
| 640 | add_timer(&ifmsh->mesh_path_timer); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 641 | if (test_and_clear_bit(TMR_RUNNING_MPR, &ifmsh->timers_running)) |
| 642 | add_timer(&ifmsh->mesh_path_root_timer); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 643 | ieee80211_mesh_root_setup(ifmsh); |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 644 | } |
| 645 | #endif |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 646 | |
| 647 | void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata) |
| 648 | { |
| 649 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 650 | struct ieee80211_local *local = sdata->local; |
Chun-Yeow Yeoh | f4eabc9 | 2012-12-13 18:59:57 +0800 | [diff] [blame] | 651 | u32 changed = BSS_CHANGED_BEACON | |
| 652 | BSS_CHANGED_BEACON_ENABLED | |
| 653 | BSS_CHANGED_HT | |
| 654 | BSS_CHANGED_BASIC_RATES | |
| 655 | BSS_CHANGED_BEACON_INT; |
| 656 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 657 | |
Johannes Berg | 09b1747 | 2010-12-03 09:20:41 +0100 | [diff] [blame] | 658 | local->fif_other_bss++; |
| 659 | /* mesh ifaces must set allmulti to forward mcast traffic */ |
| 660 | atomic_inc(&local->iff_allmultis); |
| 661 | ieee80211_configure_filter(local); |
| 662 | |
Javier Cardona | c7108a7 | 2010-12-16 17:37:50 -0800 | [diff] [blame] | 663 | ifmsh->mesh_cc_id = 0; /* Disabled */ |
Javier Cardona | c7108a7 | 2010-12-16 17:37:50 -0800 | [diff] [blame] | 664 | ifmsh->mesh_auth_id = 0; /* Disabled */ |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 665 | /* register sync ops from extensible synchronization framework */ |
| 666 | ifmsh->sync_ops = ieee80211_mesh_sync_ops_get(ifmsh->mesh_sp_id); |
| 667 | ifmsh->adjusting_tbtt = false; |
| 668 | ifmsh->sync_offset_clockdrift_max = 0; |
Rui Paulo | 6b9ac44 | 2009-10-20 21:21:48 +0100 | [diff] [blame] | 669 | set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 670 | ieee80211_mesh_root_setup(ifmsh); |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 671 | ieee80211_queue_work(&local->hw, &sdata->work); |
Ashok Nagarajan | 70c33ea | 2012-04-30 14:20:32 -0700 | [diff] [blame] | 672 | sdata->vif.bss_conf.ht_operation_mode = |
| 673 | ifmsh->mshcfg.ht_opmode; |
Johannes Berg | d6a8322 | 2012-12-14 14:06:28 +0100 | [diff] [blame] | 674 | sdata->vif.bss_conf.enable_beacon = true; |
Ashok Nagarajan | d934f7d | 2012-04-02 21:21:19 -0700 | [diff] [blame] | 675 | sdata->vif.bss_conf.basic_rates = |
Chun-Yeow Yeoh | f4eabc9 | 2012-12-13 18:59:57 +0800 | [diff] [blame] | 676 | ieee80211_mandatory_rates(local, band); |
| 677 | |
Thomas Pedersen | 39886b6 | 2013-02-13 12:14:19 -0800 | [diff] [blame^] | 678 | changed |= ieee80211_mps_local_status_update(sdata); |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 679 | |
Chun-Yeow Yeoh | f4eabc9 | 2012-12-13 18:59:57 +0800 | [diff] [blame] | 680 | ieee80211_bss_info_change_notify(sdata, changed); |
Johannes Berg | c405c62 | 2012-07-30 19:44:12 +0200 | [diff] [blame] | 681 | |
| 682 | netif_carrier_on(sdata->dev); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) |
| 686 | { |
Johannes Berg | 09b1747 | 2010-12-03 09:20:41 +0100 | [diff] [blame] | 687 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 688 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 689 | |
Johannes Berg | c405c62 | 2012-07-30 19:44:12 +0200 | [diff] [blame] | 690 | netif_carrier_off(sdata->dev); |
| 691 | |
Thomas Pedersen | 0d466b9c | 2012-08-03 12:21:32 -0700 | [diff] [blame] | 692 | /* stop the beacon */ |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 693 | ifmsh->mesh_id_len = 0; |
Johannes Berg | d6a8322 | 2012-12-14 14:06:28 +0100 | [diff] [blame] | 694 | sdata->vif.bss_conf.enable_beacon = false; |
| 695 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 696 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
Thomas Pedersen | 0d466b9c | 2012-08-03 12:21:32 -0700 | [diff] [blame] | 697 | |
| 698 | /* flush STAs and mpaths on this iface */ |
Johannes Berg | b998e8b | 2012-12-13 23:07:46 +0100 | [diff] [blame] | 699 | sta_info_flush(sdata); |
Thomas Pedersen | 0d466b9c | 2012-08-03 12:21:32 -0700 | [diff] [blame] | 700 | mesh_path_flush_by_iface(sdata); |
Johannes Berg | 09b1747 | 2010-12-03 09:20:41 +0100 | [diff] [blame] | 701 | |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 702 | /* free all potentially still buffered group-addressed frames */ |
| 703 | local->total_ps_buffered -= skb_queue_len(&ifmsh->ps.bc_buf); |
| 704 | skb_queue_purge(&ifmsh->ps.bc_buf); |
| 705 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 706 | del_timer_sync(&sdata->u.mesh.housekeeping_timer); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 707 | del_timer_sync(&sdata->u.mesh.mesh_path_root_timer); |
Johannes Berg | dd4c926 | 2012-08-01 21:03:21 +0200 | [diff] [blame] | 708 | del_timer_sync(&sdata->u.mesh.mesh_path_timer); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 709 | /* |
Johannes Berg | b741343 | 2008-09-11 00:01:50 +0200 | [diff] [blame] | 710 | * If the timer fired while we waited for it, it will have |
| 711 | * requeued the work. Now the work will be running again |
| 712 | * but will not rearm the timer again because it checks |
| 713 | * whether the interface is running, which, at this point, |
| 714 | * it no longer is. |
| 715 | */ |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 716 | cancel_work_sync(&sdata->work); |
Johannes Berg | 09b1747 | 2010-12-03 09:20:41 +0100 | [diff] [blame] | 717 | |
| 718 | local->fif_other_bss--; |
| 719 | atomic_dec(&local->iff_allmultis); |
| 720 | ieee80211_configure_filter(local); |
Johannes Berg | 2d9957c | 2012-08-01 20:54:52 +0200 | [diff] [blame] | 721 | |
| 722 | sdata->u.mesh.timers_running = 0; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, |
| 726 | u16 stype, |
| 727 | struct ieee80211_mgmt *mgmt, |
| 728 | size_t len, |
| 729 | struct ieee80211_rx_status *rx_status) |
| 730 | { |
Johannes Berg | c6a1fa1 | 2008-10-07 12:04:32 +0200 | [diff] [blame] | 731 | struct ieee80211_local *local = sdata->local; |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 732 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 733 | struct ieee802_11_elems elems; |
| 734 | struct ieee80211_channel *channel; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 735 | size_t baselen; |
| 736 | int freq; |
| 737 | enum ieee80211_band band = rx_status->band; |
| 738 | |
| 739 | /* ignore ProbeResp to foreign address */ |
| 740 | if (stype == IEEE80211_STYPE_PROBE_RESP && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 741 | !ether_addr_equal(mgmt->da, sdata->vif.addr)) |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 742 | return; |
| 743 | |
| 744 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
| 745 | if (baselen > len) |
| 746 | return; |
| 747 | |
| 748 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
| 749 | &elems); |
| 750 | |
Thomas Pedersen | 9a90bc8 | 2012-10-20 19:03:10 -0700 | [diff] [blame] | 751 | /* ignore non-mesh or secure / unsecure mismatch */ |
| 752 | if ((!elems.mesh_id || !elems.mesh_config) || |
| 753 | (elems.rsn && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) || |
| 754 | (!elems.rsn && sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)) |
Javier Cardona | 5cff5e0 | 2011-04-07 15:08:29 -0700 | [diff] [blame] | 755 | return; |
| 756 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 757 | if (elems.ds_params && elems.ds_params_len == 1) |
Bruno Randolf | 59eb21a | 2011-01-17 13:37:28 +0900 | [diff] [blame] | 758 | freq = ieee80211_channel_to_frequency(elems.ds_params[0], band); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 759 | else |
| 760 | freq = rx_status->freq; |
| 761 | |
| 762 | channel = ieee80211_get_channel(local->hw.wiphy, freq); |
| 763 | |
| 764 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) |
| 765 | return; |
| 766 | |
Thomas Pedersen | 9a90bc8 | 2012-10-20 19:03:10 -0700 | [diff] [blame] | 767 | if (mesh_matches_local(sdata, &elems)) |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 768 | mesh_neighbour_update(sdata, mgmt->sa, &elems); |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 769 | |
| 770 | if (ifmsh->sync_ops) |
| 771 | ifmsh->sync_ops->rx_bcn_presp(sdata, |
| 772 | stype, mgmt, &elems, rx_status); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata, |
| 776 | struct ieee80211_mgmt *mgmt, |
| 777 | size_t len, |
| 778 | struct ieee80211_rx_status *rx_status) |
| 779 | { |
| 780 | switch (mgmt->u.action.category) { |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 781 | case WLAN_CATEGORY_SELF_PROTECTED: |
| 782 | switch (mgmt->u.action.u.self_prot.action_code) { |
| 783 | case WLAN_SP_MESH_PEERING_OPEN: |
| 784 | case WLAN_SP_MESH_PEERING_CLOSE: |
| 785 | case WLAN_SP_MESH_PEERING_CONFIRM: |
| 786 | mesh_rx_plink_frame(sdata, mgmt, len, rx_status); |
| 787 | break; |
| 788 | } |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 789 | break; |
Thomas Pedersen | 25d49e4 | 2011-08-11 19:35:15 -0700 | [diff] [blame] | 790 | case WLAN_CATEGORY_MESH_ACTION: |
| 791 | if (mesh_action_is_path_sel(mgmt)) |
| 792 | mesh_rx_path_sel_frame(sdata, mgmt, len); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 793 | break; |
| 794 | } |
| 795 | } |
| 796 | |
Johannes Berg | 1fa57d0 | 2010-06-10 10:21:32 +0200 | [diff] [blame] | 797 | void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, |
| 798 | struct sk_buff *skb) |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 799 | { |
| 800 | struct ieee80211_rx_status *rx_status; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 801 | struct ieee80211_mgmt *mgmt; |
| 802 | u16 stype; |
| 803 | |
Johannes Berg | f1d58c2 | 2009-06-17 13:13:00 +0200 | [diff] [blame] | 804 | rx_status = IEEE80211_SKB_RXCB(skb); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 805 | mgmt = (struct ieee80211_mgmt *) skb->data; |
| 806 | stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; |
| 807 | |
| 808 | switch (stype) { |
| 809 | case IEEE80211_STYPE_PROBE_RESP: |
| 810 | case IEEE80211_STYPE_BEACON: |
| 811 | ieee80211_mesh_rx_bcn_presp(sdata, stype, mgmt, skb->len, |
| 812 | rx_status); |
| 813 | break; |
| 814 | case IEEE80211_STYPE_ACTION: |
| 815 | ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status); |
| 816 | break; |
| 817 | } |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 818 | } |
| 819 | |
Johannes Berg | 1fa57d0 | 2010-06-10 10:21:32 +0200 | [diff] [blame] | 820 | void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 821 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 822 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 823 | |
| 824 | if (ifmsh->preq_queue_len && |
| 825 | time_after(jiffies, |
| 826 | ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval))) |
| 827 | mesh_path_start_discovery(sdata); |
| 828 | |
Javier Cardona | 1888923 | 2009-08-10 12:15:52 -0700 | [diff] [blame] | 829 | if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags)) |
| 830 | mesh_mpath_table_grow(); |
| 831 | |
Nick Ledovskikh | dcac908 | 2011-01-11 14:35:12 +0000 | [diff] [blame] | 832 | if (test_and_clear_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags)) |
Javier Cardona | 1888923 | 2009-08-10 12:15:52 -0700 | [diff] [blame] | 833 | mesh_mpp_table_grow(); |
| 834 | |
| 835 | if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags)) |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 836 | ieee80211_mesh_housekeeping(sdata, ifmsh); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 837 | |
| 838 | if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags)) |
| 839 | ieee80211_mesh_rootpath(sdata); |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 840 | |
| 841 | if (test_and_clear_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags)) |
| 842 | mesh_sync_adjust_tbtt(sdata); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) |
| 846 | { |
| 847 | struct ieee80211_sub_if_data *sdata; |
| 848 | |
| 849 | rcu_read_lock(); |
| 850 | list_for_each_entry_rcu(sdata, &local->interfaces, list) |
| 851 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 852 | ieee80211_queue_work(&local->hw, &sdata->work); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 853 | rcu_read_unlock(); |
| 854 | } |
| 855 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 856 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) |
| 857 | { |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 858 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Johannes Berg | ad2d223 | 2012-12-14 14:34:25 +0100 | [diff] [blame] | 859 | static u8 zero_addr[ETH_ALEN] = {}; |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 860 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 861 | setup_timer(&ifmsh->housekeeping_timer, |
| 862 | ieee80211_mesh_housekeeping_timer, |
| 863 | (unsigned long) sdata); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 864 | |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 865 | ifmsh->accepting_plinks = true; |
| 866 | ifmsh->preq_id = 0; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 867 | ifmsh->sn = 0; |
Javier Cardona | 5ee68e5 | 2011-08-09 16:45:08 -0700 | [diff] [blame] | 868 | ifmsh->num_gates = 0; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 869 | atomic_set(&ifmsh->mpaths, 0); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 870 | mesh_rmc_init(sdata); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 871 | ifmsh->last_preq = jiffies; |
Thomas Pedersen | dca7e94 | 2011-11-24 17:15:24 -0800 | [diff] [blame] | 872 | ifmsh->next_perr = jiffies; |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 873 | /* Allocate all mesh structures when creating the first mesh interface. */ |
| 874 | if (!mesh_allocated) |
| 875 | ieee80211s_init(); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 876 | setup_timer(&ifmsh->mesh_path_timer, |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 877 | ieee80211_mesh_path_timer, |
| 878 | (unsigned long) sdata); |
Rui Paulo | e304bfd | 2009-11-09 23:46:56 +0000 | [diff] [blame] | 879 | setup_timer(&ifmsh->mesh_path_root_timer, |
| 880 | ieee80211_mesh_path_root_timer, |
| 881 | (unsigned long) sdata); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 882 | INIT_LIST_HEAD(&ifmsh->preq_queue.list); |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 883 | skb_queue_head_init(&ifmsh->ps.bc_buf); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 884 | spin_lock_init(&ifmsh->mesh_preq_queue_lock); |
Javier Cardona | dbf498f | 2012-03-31 11:31:32 -0700 | [diff] [blame] | 885 | spin_lock_init(&ifmsh->sync_offset_lock); |
Johannes Berg | ad2d223 | 2012-12-14 14:34:25 +0100 | [diff] [blame] | 886 | |
| 887 | sdata->vif.bss_conf.bssid = zero_addr; |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 888 | } |