00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <linux/slab.h>
00012 #include <asm/unaligned.h>
00013 #include "ieee80211_i.h"
00014 #include "mesh.h"
00015
00016 #define MESHCONF_CAPAB_ACCEPT_PLINKS 0x01
00017 #define MESHCONF_CAPAB_FORWARDING 0x08
00018
00019 #define TMR_RUNNING_HK 0
00020 #define TMR_RUNNING_MP 1
00021 #define TMR_RUNNING_MPR 2
00022
00023 int mesh_allocated;
00024 static struct kmem_cache *rm_cache;
00025
00026 #ifdef CONFIG_MAC80211_MESH
00027 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
00028 {
00029 return (mgmt->u.action.u.mesh_action.action_code ==
00030 WLAN_MESH_ACTION_HWMP_PATH_SELECTION);
00031 }
00032 #else
00033 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
00034 { return false; }
00035 #endif
00036
00037 void ieee80211s_init(void)
00038 {
00039 mesh_pathtbl_init();
00040 mesh_allocated = 1;
00041 rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
00042 0, 0, NULL);
00043 }
00044
00045 void ieee80211s_stop(void)
00046 {
00047 mesh_pathtbl_unregister();
00048 kmem_cache_destroy(rm_cache);
00049 }
00050
00051 static void ieee80211_mesh_housekeeping_timer(unsigned long data)
00052 {
00053 struct ieee80211_sub_if_data *sdata = (void *) data;
00054 struct ieee80211_local *local = sdata->local;
00055 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00056
00057 set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
00058
00059 if (local->quiescing) {
00060 set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
00061 return;
00062 }
00063
00064 ieee80211_queue_work(&local->hw, &sdata->work);
00065 }
00066
00076 bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_data *sdata)
00077 {
00078 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 if (ifmsh->mesh_id_len == ie->mesh_id_len &&
00091 memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
00092 (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) &&
00093 (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) &&
00094 (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) &&
00095 (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) &&
00096 (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))
00097 return true;
00098
00099 return false;
00100 }
00101
00107 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
00108 {
00109 return (ie->mesh_config->meshconf_cap &
00110 MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
00111 }
00112
00118 void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
00119 {
00120 bool free_plinks;
00121
00122
00123
00124
00125
00126
00127
00128 free_plinks = mesh_plink_availables(sdata);
00129
00130 if (free_plinks != sdata->u.mesh.accepting_plinks)
00131 ieee80211_mesh_housekeeping_timer((unsigned long) sdata);
00132 }
00133
00134 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata)
00135 {
00136 int i;
00137
00138 sdata->u.mesh.rmc = kmalloc(sizeof(struct mesh_rmc), GFP_KERNEL);
00139 if (!sdata->u.mesh.rmc)
00140 return -ENOMEM;
00141 sdata->u.mesh.rmc->idx_mask = RMC_BUCKETS - 1;
00142 for (i = 0; i < RMC_BUCKETS; i++)
00143 INIT_LIST_HEAD(&sdata->u.mesh.rmc->bucket[i].list);
00144 return 0;
00145 }
00146
00147 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata)
00148 {
00149 struct mesh_rmc *rmc = sdata->u.mesh.rmc;
00150 struct rmc_entry *p, *n;
00151 int i;
00152
00153 if (!sdata->u.mesh.rmc)
00154 return;
00155
00156 for (i = 0; i < RMC_BUCKETS; i++)
00157 list_for_each_entry_safe(p, n, &rmc->bucket[i].list, list) {
00158 list_del(&p->list);
00159 kmem_cache_free(rm_cache, p);
00160 }
00161
00162 kfree(rmc);
00163 sdata->u.mesh.rmc = NULL;
00164 }
00165
00178 int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
00179 struct ieee80211_sub_if_data *sdata)
00180 {
00181 struct mesh_rmc *rmc = sdata->u.mesh.rmc;
00182 u32 seqnum = 0;
00183 int entries = 0;
00184 u8 idx;
00185 struct rmc_entry *p, *n;
00186
00187
00188 memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
00189 idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask;
00190 list_for_each_entry_safe(p, n, &rmc->bucket[idx].list, list) {
00191 ++entries;
00192 if (time_after(jiffies, p->exp_time) ||
00193 (entries == RMC_QUEUE_MAX_LEN)) {
00194 list_del(&p->list);
00195 kmem_cache_free(rm_cache, p);
00196 --entries;
00197 } else if ((seqnum == p->seqnum) &&
00198 (memcmp(sa, p->sa, ETH_ALEN) == 0))
00199 return -1;
00200 }
00201
00202 p = kmem_cache_alloc(rm_cache, GFP_ATOMIC);
00203 if (!p)
00204 return 0;
00205
00206 p->seqnum = seqnum;
00207 p->exp_time = jiffies + RMC_TIMEOUT;
00208 memcpy(p->sa, sa, ETH_ALEN);
00209 list_add(&p->list, &rmc->bucket[idx].list);
00210 return 0;
00211 }
00212
00213 int
00214 mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
00215 {
00216 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00217 u8 *pos, neighbors;
00218 u8 meshconf_len = sizeof(struct ieee80211_meshconf_ie);
00219
00220 if (skb_tailroom(skb) < 2 + meshconf_len)
00221 return -ENOMEM;
00222
00223 pos = skb_put(skb, 2 + meshconf_len);
00224 *pos++ = WLAN_EID_MESH_CONFIG;
00225 *pos++ = meshconf_len;
00226
00227
00228 *pos++ = ifmsh->mesh_pp_id;
00229
00230 *pos++ = ifmsh->mesh_pm_id;
00231
00232 *pos++ = ifmsh->mesh_cc_id;
00233
00234 *pos++ = ifmsh->mesh_sp_id;
00235
00236 *pos++ = ifmsh->mesh_auth_id;
00237
00238 neighbors = atomic_read(&ifmsh->mshstats.estab_plinks);
00239
00240 neighbors = (neighbors > 15) ? 15 : neighbors;
00241 *pos++ = neighbors << 1;
00242
00243 ifmsh->accepting_plinks = mesh_plink_availables(sdata);
00244 *pos = MESHCONF_CAPAB_FORWARDING;
00245 *pos++ |= ifmsh->accepting_plinks ?
00246 MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00;
00247 *pos++ = 0x00;
00248
00249 return 0;
00250 }
00251
00252 int
00253 mesh_add_meshid_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
00254 {
00255 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00256 u8 *pos;
00257
00258 if (skb_tailroom(skb) < 2 + ifmsh->mesh_id_len)
00259 return -ENOMEM;
00260
00261 pos = skb_put(skb, 2 + ifmsh->mesh_id_len);
00262 *pos++ = WLAN_EID_MESH_ID;
00263 *pos++ = ifmsh->mesh_id_len;
00264 if (ifmsh->mesh_id_len)
00265 memcpy(pos, ifmsh->mesh_id, ifmsh->mesh_id_len);
00266
00267 return 0;
00268 }
00269
00270 int
00271 mesh_add_vendor_ies(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
00272 {
00273 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00274 u8 offset, len;
00275 const u8 *data;
00276
00277 if (!ifmsh->ie || !ifmsh->ie_len)
00278 return 0;
00279
00280
00281 offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
00282
00283 if (offset) {
00284 len = ifmsh->ie_len - offset;
00285 data = ifmsh->ie + offset;
00286 if (skb_tailroom(skb) < len)
00287 return -ENOMEM;
00288 memcpy(skb_put(skb, len), data, len);
00289 }
00290
00291 return 0;
00292 }
00293
00294 int
00295 mesh_add_rsn_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
00296 {
00297 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00298 u8 len = 0;
00299 const u8 *data;
00300
00301 if (!ifmsh->ie || !ifmsh->ie_len)
00302 return 0;
00303
00304
00305 data = ifmsh->ie;
00306 while (data < ifmsh->ie + ifmsh->ie_len) {
00307 if (*data == WLAN_EID_RSN) {
00308 len = data[1] + 2;
00309 break;
00310 }
00311 data++;
00312 }
00313
00314 if (len) {
00315 if (skb_tailroom(skb) < len)
00316 return -ENOMEM;
00317 memcpy(skb_put(skb, len), data, len);
00318 }
00319
00320 return 0;
00321 }
00322
00323 int mesh_add_ds_params_ie(struct sk_buff *skb,
00324 struct ieee80211_sub_if_data *sdata)
00325 {
00326 struct ieee80211_local *local = sdata->local;
00327 struct ieee80211_supported_band *sband;
00328 u8 *pos;
00329
00330 if (skb_tailroom(skb) < 3)
00331 return -ENOMEM;
00332
00333 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
00334 if (sband->band == IEEE80211_BAND_2GHZ) {
00335 pos = skb_put(skb, 2 + 1);
00336 *pos++ = WLAN_EID_DS_PARAMS;
00337 *pos++ = 1;
00338 *pos++ = ieee80211_frequency_to_channel(local->hw.conf.channel->center_freq);
00339 }
00340
00341 return 0;
00342 }
00343
00344 static void ieee80211_mesh_path_timer(unsigned long data)
00345 {
00346 struct ieee80211_sub_if_data *sdata =
00347 (struct ieee80211_sub_if_data *) data;
00348 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00349 struct ieee80211_local *local = sdata->local;
00350
00351 if (local->quiescing) {
00352 set_bit(TMR_RUNNING_MP, &ifmsh->timers_running);
00353 return;
00354 }
00355
00356 ieee80211_queue_work(&local->hw, &sdata->work);
00357 }
00358
00359 static void ieee80211_mesh_path_root_timer(unsigned long data)
00360 {
00361 struct ieee80211_sub_if_data *sdata =
00362 (struct ieee80211_sub_if_data *) data;
00363 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00364 struct ieee80211_local *local = sdata->local;
00365
00366 set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
00367
00368 if (local->quiescing) {
00369 set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running);
00370 return;
00371 }
00372
00373 ieee80211_queue_work(&local->hw, &sdata->work);
00374 }
00375
00376 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh)
00377 {
00378 if (ifmsh->mshcfg.dot11MeshHWMPRootMode)
00379 set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
00380 else {
00381 clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
00382
00383 del_timer_sync(&ifmsh->mesh_path_root_timer);
00384 }
00385 }
00386
00397 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
00398 const u8 *meshda, const u8 *meshsa)
00399 {
00400 if (is_multicast_ether_addr(meshda)) {
00401 *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
00402
00403 memcpy(hdr->addr1, meshda, ETH_ALEN);
00404 memcpy(hdr->addr2, meshsa, ETH_ALEN);
00405 memcpy(hdr->addr3, meshsa, ETH_ALEN);
00406 return 24;
00407 } else {
00408 *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
00409
00410 memset(hdr->addr1, 0, ETH_ALEN);
00411 memcpy(hdr->addr2, meshsa, ETH_ALEN);
00412 memcpy(hdr->addr3, meshda, ETH_ALEN);
00413 memcpy(hdr->addr4, meshsa, ETH_ALEN);
00414 return 30;
00415 }
00416 }
00417
00430 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
00431 struct ieee80211_sub_if_data *sdata, char *addr4or5,
00432 char *addr6)
00433 {
00434 int aelen = 0;
00435 BUG_ON(!addr4or5 && addr6);
00436 memset(meshhdr, 0, sizeof(*meshhdr));
00437 meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
00438 put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum);
00439 sdata->u.mesh.mesh_seqnum++;
00440 if (addr4or5 && !addr6) {
00441 meshhdr->flags |= MESH_FLAGS_AE_A4;
00442 aelen += ETH_ALEN;
00443 memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
00444 } else if (addr4or5 && addr6) {
00445 meshhdr->flags |= MESH_FLAGS_AE_A5_A6;
00446 aelen += 2 * ETH_ALEN;
00447 memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
00448 memcpy(meshhdr->eaddr2, addr6, ETH_ALEN);
00449 }
00450 return 6 + aelen;
00451 }
00452
00453 static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata,
00454 struct ieee80211_if_mesh *ifmsh)
00455 {
00456 bool free_plinks;
00457
00458 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
00459 printk(KERN_DEBUG "%s: running mesh housekeeping\n",
00460 sdata->name);
00461 #endif
00462
00463 ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT);
00464 mesh_path_expire(sdata);
00465
00466 free_plinks = mesh_plink_availables(sdata);
00467 if (free_plinks != sdata->u.mesh.accepting_plinks)
00468 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
00469
00470 mod_timer(&ifmsh->housekeeping_timer,
00471 round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL));
00472 }
00473
00474 static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata)
00475 {
00476 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00477
00478 mesh_path_tx_root_frame(sdata);
00479 mod_timer(&ifmsh->mesh_path_root_timer,
00480 round_jiffies(TU_TO_EXP_TIME(
00481 ifmsh->mshcfg.dot11MeshHWMPRannInterval)));
00482 }
00483
00484 #ifdef CONFIG_PM
00485 void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
00486 {
00487 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00488
00489
00490
00491 if (del_timer_sync(&ifmsh->housekeeping_timer))
00492 set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
00493 if (del_timer_sync(&ifmsh->mesh_path_timer))
00494 set_bit(TMR_RUNNING_MP, &ifmsh->timers_running);
00495 if (del_timer_sync(&ifmsh->mesh_path_root_timer))
00496 set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running);
00497 }
00498
00499 void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
00500 {
00501 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00502
00503 if (test_and_clear_bit(TMR_RUNNING_HK, &ifmsh->timers_running))
00504 add_timer(&ifmsh->housekeeping_timer);
00505 if (test_and_clear_bit(TMR_RUNNING_MP, &ifmsh->timers_running))
00506 add_timer(&ifmsh->mesh_path_timer);
00507 if (test_and_clear_bit(TMR_RUNNING_MPR, &ifmsh->timers_running))
00508 add_timer(&ifmsh->mesh_path_root_timer);
00509 ieee80211_mesh_root_setup(ifmsh);
00510 }
00511 #endif
00512
00513 void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
00514 {
00515 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00516 struct ieee80211_local *local = sdata->local;
00517
00518 local->fif_other_bss++;
00519
00520 atomic_inc(&local->iff_allmultis);
00521 ieee80211_configure_filter(local);
00522
00523 ifmsh->mesh_cc_id = 0;
00524 ifmsh->mesh_sp_id = 0;
00525 ifmsh->mesh_auth_id = 0;
00526 set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
00527 ieee80211_mesh_root_setup(ifmsh);
00528 ieee80211_queue_work(&local->hw, &sdata->work);
00529 sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL;
00530 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON |
00531 BSS_CHANGED_BEACON_ENABLED |
00532 BSS_CHANGED_BEACON_INT);
00533 }
00534
00535 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
00536 {
00537 struct ieee80211_local *local = sdata->local;
00538 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00539
00540 ifmsh->mesh_id_len = 0;
00541 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
00542 sta_info_flush(local, NULL);
00543
00544 del_timer_sync(&sdata->u.mesh.housekeeping_timer);
00545 del_timer_sync(&sdata->u.mesh.mesh_path_root_timer);
00546 del_timer_sync(&sdata->u.mesh.mesh_path_timer);
00547
00548
00549
00550
00551
00552
00553
00554 cancel_work_sync(&sdata->work);
00555
00556 local->fif_other_bss--;
00557 atomic_dec(&local->iff_allmultis);
00558 ieee80211_configure_filter(local);
00559 }
00560
00561 static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
00562 u16 stype,
00563 struct ieee80211_mgmt *mgmt,
00564 size_t len,
00565 struct ieee80211_rx_status *rx_status)
00566 {
00567 struct ieee80211_local *local = sdata->local;
00568 struct ieee802_11_elems elems;
00569 struct ieee80211_channel *channel;
00570 u32 supp_rates = 0;
00571 size_t baselen;
00572 int freq;
00573 enum ieee80211_band band = rx_status->band;
00574
00575
00576 if (stype == IEEE80211_STYPE_PROBE_RESP &&
00577 compare_ether_addr(mgmt->da, sdata->vif.addr))
00578 return;
00579
00580 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
00581 if (baselen > len)
00582 return;
00583
00584 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
00585 &elems);
00586
00587
00588 if (elems.rsn_len && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE)
00589 return;
00590
00591 if (elems.ds_params && elems.ds_params_len == 1)
00592 freq = ieee80211_channel_to_frequency(elems.ds_params[0], band);
00593 else
00594 freq = rx_status->freq;
00595
00596 channel = ieee80211_get_channel(local->hw.wiphy, freq);
00597
00598 if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
00599 return;
00600
00601 if (elems.mesh_id && elems.mesh_config &&
00602 mesh_matches_local(&elems, sdata)) {
00603 supp_rates = ieee80211_sta_get_rates(local, &elems, band);
00604 mesh_neighbour_update(mgmt->sa, supp_rates, sdata, &elems);
00605 }
00606 }
00607
00608 static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
00609 struct ieee80211_mgmt *mgmt,
00610 size_t len,
00611 struct ieee80211_rx_status *rx_status)
00612 {
00613 switch (mgmt->u.action.category) {
00614 case WLAN_CATEGORY_SELF_PROTECTED:
00615 switch (mgmt->u.action.u.self_prot.action_code) {
00616 case WLAN_SP_MESH_PEERING_OPEN:
00617 case WLAN_SP_MESH_PEERING_CLOSE:
00618 case WLAN_SP_MESH_PEERING_CONFIRM:
00619 mesh_rx_plink_frame(sdata, mgmt, len, rx_status);
00620 break;
00621 }
00622 break;
00623 case WLAN_CATEGORY_MESH_ACTION:
00624 if (mesh_action_is_path_sel(mgmt))
00625 mesh_rx_path_sel_frame(sdata, mgmt, len);
00626 break;
00627 }
00628 }
00629
00630 void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
00631 struct sk_buff *skb)
00632 {
00633 struct ieee80211_rx_status *rx_status;
00634 struct ieee80211_mgmt *mgmt;
00635 u16 stype;
00636
00637 rx_status = IEEE80211_SKB_RXCB(skb);
00638 mgmt = (struct ieee80211_mgmt *) skb->data;
00639 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
00640
00641 switch (stype) {
00642 case IEEE80211_STYPE_PROBE_RESP:
00643 case IEEE80211_STYPE_BEACON:
00644 ieee80211_mesh_rx_bcn_presp(sdata, stype, mgmt, skb->len,
00645 rx_status);
00646 break;
00647 case IEEE80211_STYPE_ACTION:
00648 ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status);
00649 break;
00650 }
00651 }
00652
00653 void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata)
00654 {
00655 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00656
00657 if (ifmsh->preq_queue_len &&
00658 time_after(jiffies,
00659 ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))
00660 mesh_path_start_discovery(sdata);
00661
00662 if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
00663 mesh_mpath_table_grow();
00664
00665 if (test_and_clear_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags))
00666 mesh_mpp_table_grow();
00667
00668 if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
00669 ieee80211_mesh_housekeeping(sdata, ifmsh);
00670
00671 if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags))
00672 ieee80211_mesh_rootpath(sdata);
00673 }
00674
00675 void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local)
00676 {
00677 struct ieee80211_sub_if_data *sdata;
00678
00679 rcu_read_lock();
00680 list_for_each_entry_rcu(sdata, &local->interfaces, list)
00681 if (ieee80211_vif_is_mesh(&sdata->vif))
00682 ieee80211_queue_work(&local->hw, &sdata->work);
00683 rcu_read_unlock();
00684 }
00685
00686 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
00687 {
00688 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
00689
00690 setup_timer(&ifmsh->housekeeping_timer,
00691 ieee80211_mesh_housekeeping_timer,
00692 (unsigned long) sdata);
00693
00694 ifmsh->accepting_plinks = true;
00695 ifmsh->preq_id = 0;
00696 ifmsh->sn = 0;
00697 ifmsh->num_gates = 0;
00698 atomic_set(&ifmsh->mpaths, 0);
00699 mesh_rmc_init(sdata);
00700 ifmsh->last_preq = jiffies;
00701
00702 if (!mesh_allocated)
00703 ieee80211s_init();
00704 setup_timer(&ifmsh->mesh_path_timer,
00705 ieee80211_mesh_path_timer,
00706 (unsigned long) sdata);
00707 setup_timer(&ifmsh->mesh_path_root_timer,
00708 ieee80211_mesh_path_root_timer,
00709 (unsigned long) sdata);
00710 INIT_LIST_HEAD(&ifmsh->preq_queue.list);
00711 spin_lock_init(&ifmsh->mesh_preq_queue_lock);
00712 }